filter.bcdc_promise | R Documentation |
Filter a query from Web Feature Service using dplyr
methods. This filtering is accomplished lazily so that
the full sf object is not read into memory until
collect()
has been called.
See dplyr::filter
for details.
## S3 method for class 'bcdc_promise'
filter(.data, ...)
.data |
object of class |
... |
Logical predicates with which to filter the results. Multiple
conditions are combined with If your filter expression contains calls that need to be executed locally, wrap them
in |
filter(bcdc_promise)
: filter.bcdc_promise
try(
crd <- bcdc_query_geodata("regional-districts-legally-defined-administrative-areas-of-bc") %>%
filter(ADMIN_AREA_NAME == "Cariboo Regional District") %>%
collect()
)
try(
ret1 <- bcdc_query_geodata("bc-wildfire-fire-perimeters-historical") %>%
filter(FIRE_YEAR == 2000, FIRE_CAUSE == "Person", INTERSECTS(crd)) %>%
collect()
)
# Use local() to force parts of your call to be evaluated in R:
try({
# Create a bounding box around two points and use that to filter
# the remote data set
library(sf)
two_points <- st_sfc(st_point(c(1164434, 368738)),
st_point(c(1203023, 412959)),
crs = 3005)
# Wrapping the call to `st_bbox()` in `local()` ensures that it
# is executed in R to make a bounding box that is then sent to
# the server for the filtering operation:
res <- bcdc_query_geodata("local-and-regional-greenspaces") %>%
filter(BBOX(local(st_bbox(two_points, crs = st_crs(two_points))))) %>%
collect()
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.