Skip to content

Commit

Permalink
correct iteration over OSM layers
Browse files Browse the repository at this point in the history
  • Loading branch information
StevePem committed Aug 13, 2024
1 parent 9bc7282 commit 605a5ef
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions functions/getOsmExtract.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ getOsmExtract <- function(region,

# convert to gpkg, including all layers ('boundary' will clip to bounding box)
echo(paste("Converting downloaded OSM extract to .gpkg for selected region\n"))
region.gpkg <-
oe_vectortranslate(full.extract,
layer = st_layers(full.extract)$name,
vectortranslate_options = c("-t_srs",
paste0("EPSG:", outputCrs)),
boundary = region.buffer,
boundary_type = "spat") # 'spat' should intersect rather than clip, but still seems to clip
layers <- st_layers(full.extract)$name
for(i in 1:length(layers)) {
layer <- layers[i]
region.gpkg <-
oe_vectortranslate(full.extract,
layer = layer,
vectortranslate_options = c("-t_srs",
paste0("EPSG:", outputCrs)),
boundary = region.buffer,
boundary_type = "spat") # 'spat' should intersect rather than clip, but still seems to clip
}

# intersect with region buffer, eliminating errors and save to permanent location
for (i in 1:length(st_layers(region.gpkg)$name)) {
Expand Down

0 comments on commit 605a5ef

Please sign in to comment.