View source: R/WFS_getfeature.R
WFS_getfeature | R Documentation |
Retrieving the requested geospatial data will most often be done by specifying
the bounding box of the region of interest or by specifying a filter to restrict
the features that will be returned. As described in
https://docs.geoserver.org/latest/en/user/filter/syntax.html
there are two ways to specify a filter: with the cql_filter
or the filter
argument. See Details .
WFS_getfeature( typename, ..., httrType = c("GET", "POST"), url = WFS_get_url(), version = WFS_get_version(), debug = F, to_sf = T, sfverbose = F, echo_request = F, httrverbose = rep(F, 4) )
typename |
Character string with the name of a feature (such as e.g. found by using |
... |
optional arguments for the |
httrType |
Character string with the type of httr request: |
url |
URL of the WFS service. See |
version |
software version for WFS service request. See |
debug |
Logical indicating the httr response is to be returned |
to_sf |
Logical indicating if a |
sfverbose |
Logical indicating if |
echo_request |
Logical indicating if the generated GET or POST request is to be echoed |
httrverbose |
Logical vector of up to four entries to be used in |
Arguments that are recognized by the GetFeature request are:
bbox
(not in combination with cql_filter
or filter
)
cql_filter
a filter derived from the plain-text language mechanism for the OGC Catalog specification.
See for an introduction the tutorial
in the GeoServer webpages. Also see the Examples
filter
an XML-based specification of a filter.
See this GeoServer page and the Examples.
And see wfsfilteraux for functions to build these XML filters
resultType
- default 'results' and alternative 'hits'. In the latter case only the number of matched features (numbeOfFeatures
in 1.1.0 or numberMatched
in 2.0.0) is returned
srsname
indicate the crs for the coordinates of the output e.g. srsname='EPSG:4326'
propertyname
the name of the fields to retrieve. The id
and geometry
fields will always be included
startIndex
number of features to skip before retrieving features ( the output with startindex=1
will start with the second feature )
maxfeatures
(version 1.1.0
) or count
(version 2.0.0
) indicates the number of features to retrieve. When the wrong argument is specified it will be translated in the other.
The GetFeature
argument outputFormat
has value 'application/json' but this can be overwritten
See vignette for more examples
a sf
object with the requested information (the 'id' variable and the geometry will always be included)
or a character string with an error message
## Not run: # examples use the default dataset ! # retrieve all fields from the first 5 features of "topp:gidw_groenbomen" : wfs1 <- WFS_getfeature("topp:gidw_groenbomen", maxfeatures=5) # retrieve all fields from all features of "topp:gidw_groenbomen" in the indicated bbox : bbox_wgs84 <- "4.860793, 52.313319, 4.861587, 52.316493,EPSG:4326" wfs2 <- WFS_getfeature("topp:gidw_groenbomen", bbox=bbox_wgs84) # retrieve all fields from all features of "topp:gidw_groenbomen" in the indicated bbox # coordinates in bbox given in same crs as the data (EPSG:28992) but we want the output coordinates in WGS84 : bbox_28992 <- "119103.4, 480726.0, 119160.1, 481078.7" wfs3 <- WFS_getfeature("topp:gidw_groenbomen", bbox=bbox_28992,srsname='EPSG:4326' ) # filter species with embedded quote (using cql_filter=) : a_species <- r"(Prunus serrulata 'Kanzan')" # embedded quote bm=stringr::str_replace_all(a_species,"'","''") # double that for cql_filter wfs4 <- WFS_getfeature("topp:gidw_groenbomen", cql_filter= glue::glue("boom_omschrijf='{bm}'") ) # filter species with embedded quote (using filter=) and two of the auxiliary functions : f5 <- build_filter(version='1.1.0' , propeq_xml('topp:boom_omschrijf',a_tree) ) wfs5 <- WFS_getfeature("topp:gidw_groenbomen", version='1.1.0', filter = f5) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.