Filtering WFS-features during Download using R-packages httr and sf?

47 Views Asked by At

I need to download specific features of the following WFS:

"https://www.gds.hessen.de/wfs2/aaa-suite/cgi-bin/alkis/vereinf/wfs"

I would like to download 1500 specific features, filtered by "gemarkung" = x, "flur" = y, "flstnrzae" = z and "flstnrnen" = q.

But I don`t know, how to include the filter within the URL in R.

Can anyone tell me, what I am doing wrong? How should I write the code to make it work?

I would be very, very grateful for any ideas and help :))

So far, I managed to download 1000 not-filtered features with the following code:

wfs_bwk <- "https://www.gds.hessen.de/wfs2/aaa-suite/cgi-bin/alkis/vereinf/wfs"
url <- parse_url(wfs_bwk)
url$query <- list(service = "wfs",
                  version = "2.0.0", # facultative
                  request = "GetFeature",
                  typenames = "ave:Flurstueck",
                  count=1000)
request <- build_url(url)
request

bel_regions <- read_sf(request)

But now I would like to download 1500 specific features, filtered by "gemarkung" = x, "flur" = y, "flstnrzae" = z and "flstnrnen" = q.

bwk_client$
  getCapabilities()$
  findFeatureTypeByName("ave:Flurstueck")$
  getDescription() %>%
  map_chr(function(x){x$getName()})

I tried it with adding a cql-filter to the url, but the filter is ignored.

url$query <- list(service = "wfs",
                  version = "2.0.0", # facultative
                  request = "GetFeature",
                  typenames = "ave:Flurstueck",
                  cql_filter="flur='2'",
                  count=1000)
request <- build_url(url)
request
0

There are 0 best solutions below