Skip to contents

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.

Usage

# S3 method for bcdc_promise
filter(.data, ...)

Arguments

.data

object of class bcdc_promise (likely passed from bcdc_query_geodata())

...

Logical predicates with which to filter the results. Multiple conditions are combined with &. Only rows where the condition evaluates to TRUE are kept. Accepts normal R expressions as well as any of the special CQL geometry functions such as WITHIN() or INTERSECTS(). If you know CQL and want to write a CQL query directly, write it enclosed in quotes, wrapped in the CQL() function. e.g., CQL("ID = '42'")

Methods (by class)

  • bcdc_promise: filter.bcdc_promise

Examples

# \donttest{
try(
  crd <- bcdc_query_geodata("regional-districts-legally-defined-administrative-areas-of-bc") %>%
    filter(ADMIN_AREA_NAME == "Cariboo Regional District") %>%
    collect()
)
#> Error : There was an issue sending this WFS request
#> ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
#> Request:
#>   URL: https://openmaps.gov.bc.ca/geo/pub/wfs
#>   POST fields:
#>     resultType=hits&SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&outputFormat=application%2Fjson&typeNames=WHSE_LEGAL_ADMIN_BOUNDARIES.ABMS_REGIONAL_DISTRICTS_SP&SRSNAME=EPSG%3A3005&CQL_FILTER=%28%22ADMIN_AREA_NAME%22%20%3D%20%27Cariboo%20Regional%20District%27%29
#>   Content-Type: application/x-www-form-urlencoded
#>   Accept-Encoding: gzip, deflate
#>   Accept: application/json, text/xml, application/xml, */*
#>   User-Agent: https://github.com/bcgov/bcdata
#> Response:
#>   status: HTTP/1.1 503
#>   date: Tue, 05 Jul 2022 21:24:29 GMT
#>   server: Apache
#>   x-frame-options: allow-from (null)
#>   x-control-flow-delay-ms: 60004
#>   content-type: text/html;charset=utf-8
#>   content-language: en
#>   content-length: 1201
#>   access-control-allow-origin: (null)
#>   access-control-allow-credentials: true
#>   access-control-allow-methods: POST, GET, OPTIONS, HEAD
#>   access-control-allow-headers: X-Requested-With, Referer, Origin, Content-Type, SOAPAction, Authorization, Accept
#>   access-control-max-age: 1000
#>   connection: close
#> 

try(
  ret1 <- bcdc_query_geodata("fire-perimeters-historical") %>%
    filter(FIRE_YEAR == 2000, FIRE_CAUSE == "Person", INTERSECTS(crd)) %>%
    collect()
)
#> Error : object "crd" not found.
#> The object passed to INTERSECTS needs to be valid sf object.
  # }