Skip to content

Commit a0ed569

Browse files
authored
Merge pull request #314 from juanfonsecaLS1/add-wkt-filter-oe-get
set value of `boundary` if `place` is sf/sfc/bbox
2 parents 90faa1d + 9f283ee commit a0ed569

6 files changed

Lines changed: 21 additions & 5 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Description: Match, download, convert and import Open Street Map data extracts
1919
License: GPL-3
2020
Encoding: UTF-8
2121
LazyData: true
22-
RoxygenNote: 7.3.2
22+
RoxygenNote: 7.3.3
2323
Roxygen: list(markdown = TRUE)
2424
URL: https://docs.ropensci.org/osmextract/, https://github.com/ropensci/osmextract
2525
BugReports: https://github.com/ropensci/osmextract/issues

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* The default directory used to store `.osm.pbf` and `.gpkg` files downloaded or created by this package has changed from `tempdir()` to `tools::R_user_dir("osmextract", "data")` ([#302](https://github.com/ropensci/osmextract/issues/302)).
66
* Bump minimum R version to 4.1.0 because that's a requirement for one of our indirect dependencies (i.e. svglite). This also ensures that we can properly use `tools::R_user_dir()` since that function was introduced in R 4.0.0 ([#302](https://github.com/ropensci/osmextract/issues/302)).
7+
* Updated the behaviour of the `oe_get` function when a `sf/sfc/bbox` is provided as input for `place`. If `boundary` is not provided, it is automatically set to match `place` so only the relevant portion of the extract is processed.
78

89
# osmextract 0.5.3
910

R/get.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@
8888
#' display a progress bar.
8989
#' @param boundary An `sf`/`sfc`/`bbox` object that will be used to create a
9090
#' spatial filter during the vectortranslate operations. The type of filter
91-
#' can be chosen using the argument `boundary_type`.
91+
#' can be chosen using the argument `boundary_type`. If `place` is an `sf`/`sfc`
92+
#' polygon or a `bbox`, then it will be used as `boundary` if the latter is not
93+
#' specified.
9294
#' @param boundary_type A character vector of length 1 specifying the type of
9395
#' spatial filter. The `spat` filter selects only those features that
9496
#' intersect a given area, while `clipsrc` also clips the geometries. Check
@@ -262,6 +264,13 @@ oe_get = function(
262264
file_url = matched_zone[["url"]]
263265
file_size = matched_zone[["file_size"]]
264266

267+
# If place is an sf/sfc polygon or bbox, use it as boundary
268+
if (is.null(boundary) && (inherits(place, "bbox") || (inherits(place, c("sf", "sfc")) && sf::st_dimension(place) == 2))) {
269+
message("Setting boundary = place to geographically subset the output.")
270+
message("Use boundary = NULL to import full extract.")
271+
boundary = place
272+
}
273+
265274
oe_read(
266275
file_path = file_url,
267276
layer = layer,

man/oe_get.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/oe_read.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/oe_vectortranslate.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)