Skip to content

Commit

Permalink
Create make_geojsons.R
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderDevisscher committed Jun 8, 2020
1 parent cb0a640 commit 5117d13
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions R-scripts/make_geojsons.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
library(rgdal)
library(here)

filelist <- dir(path = here("Data", "Spatial"), pattern = ".shp")

filelist <- gsub(pattern = ".xml", replacement = "", filelist)
filelist <- gsub(pattern = ".shp", replacement = "", filelist)
filelist <- unique(filelist)

for(f in filelist){
fn <- paste0(f, ".geojson")
if(!file.exists(here("Data", "Spatial", fn))){
shape <- readOGR(here("Data", "Spatial"),f, stringsAsFactors = FALSE)
writeOGR(shape, here("Data", "Spatial", fn), layer=f, driver="GeoJSON",overwrite_layer=T)
}
}


0 comments on commit 5117d13

Please sign in to comment.