| Title: | Read Vector Features from Web Feature Services and Friends |
|---|---|
| Description: | Read vector features from OGC Web Feature Services (WFS), OGC API Features (OAPIF), and ArcGIS REST FeatureServer/MapServer endpoints. Uses GDAL's OGR vector drivers via 'gdalraster' for connection handling and returns tibbles with 'wk' geometry columns. Provides service discovery, layer listing, capability inspection, and bbox-filtered feature retrieval. Aims to make navigating public vector web services less painful. |
| Authors: | Michael Sumner [aut, cre] |
| Maintainer: | Michael Sumner <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-15 09:35:05 UTC |
| Source: | https://github.com/hypertidy/readwfs |
Pre-configured bounding boxes for example areas.
wfs_example_bbox(area = c("sandy_bay", "hobart"))wfs_example_bbox(area = c("sandy_bay", "hobart"))
area |
Character. One of:
|
A named numeric vector (xmin, ymin, xmax, ymax).
wfs_example_bbox("sandy_bay") wfs_example_bbox("hobart")wfs_example_bbox("sandy_bay") wfs_example_bbox("hobart")
Pre-configured URLs for example services used in documentation, vignettes, and testing.
wfs_example_url(service = c("list_tasmania", "esri_sample"))wfs_example_url(service = c("list_tasmania", "esri_sample"))
service |
Character. One of:
|
A character string with the service URL.
wfs_example_url("list_tasmania") wfs_example_url("esri_sample")wfs_example_url("list_tasmania") wfs_example_url("esri_sample")
Returns a tibble describing each non-geometry field in a layer: name, type, width, and whether it's nullable.
wfs_fields(base_url, layer, driver = "auto", version = NULL, srs = NULL)wfs_fields(base_url, layer, driver = "auto", version = NULL, srs = NULL)
base_url |
Character. The service endpoint URL. |
layer |
Character. Layer name. |
driver, version, srs
|
Passed to |
A tibble::tibble with columns: name, type, width,
precision, is_nullable.
## Not run: url <- wfs_example_url("list_tasmania") wfs_fields(url, "Public_OpenDataWFS:LIST_Cadastral_Parcels", version = "2.0.0", srs = "EPSG:28355") ## End(Not run)## Not run: url <- wfs_example_url("list_tasmania") wfs_fields(url, "Public_OpenDataWFS:LIST_Cadastral_Parcels", version = "2.0.0", srs = "EPSG:28355") ## End(Not run)
A convenience wrapper around wfs_layers() that filters results with
grep(). Useful when a service has dozens or hundreds of layers.
wfs_find_layers( base_url, pattern, driver = "auto", version = NULL, srs = NULL, ignore.case = TRUE )wfs_find_layers( base_url, pattern, driver = "auto", version = NULL, srs = NULL, ignore.case = TRUE )
base_url |
Character. The service endpoint URL. Can be a raw URL
or a GDAL-prefixed connection string (e.g. |
pattern |
Character. A regular expression to match against layer names. |
driver |
Character. One of |
version |
Character or |
srs |
Character or |
ignore.case |
Logical. Passed to |
A character vector of matching layer names.
## Not run: url <- wfs_example_url("list_tasmania") wfs_find_layers(url, "CADASTRAL|TASVEG") ## End(Not run)## Not run: url <- wfs_example_url("list_tasmania") wfs_find_layers(url, "CADASTRAL|TASVEG") ## End(Not run)
Returns a tibble describing each layer: geometry type, feature count (if available), spatial extent, and spatial reference.
wfs_layer_info( base_url, layers = NULL, driver = "auto", version = NULL, srs = NULL )wfs_layer_info( base_url, layers = NULL, driver = "auto", version = NULL, srs = NULL )
base_url |
Character. The service endpoint URL. Can be a raw URL
or a GDAL-prefixed connection string (e.g. |
layers |
Character vector of layer names to inspect, or |
driver |
Character. One of |
version |
Character or |
srs |
Character or |
A tibble::tibble with columns: name, geom_column,
geom_type, feature_count, xmin, ymin, xmax, ymax, srs_wkt.
## Not run: url <- wfs_example_url("list_tasmania") wfs_layer_info(url, layers = "Public_OpenDataWFS:LIST_Cadastral_Parcels", version = "2.0.0", srs = "EPSG:28355") ## End(Not run)## Not run: url <- wfs_example_url("list_tasmania") wfs_layer_info(url, layers = "Public_OpenDataWFS:LIST_Cadastral_Parcels", version = "2.0.0", srs = "EPSG:28355") ## End(Not run)
Queries the service endpoint and returns the names of all available feature types / layers.
wfs_layers(base_url, driver = "auto", version = NULL, srs = NULL)wfs_layers(base_url, driver = "auto", version = NULL, srs = NULL)
base_url |
Character. The service endpoint URL. Can be a raw URL
or a GDAL-prefixed connection string (e.g. |
driver |
Character. One of |
version |
Character or |
srs |
Character or |
A character vector of layer names.
## Not run: # Tasmania LIST WFS wfs_layers(wfs_example_url("list_tasmania")) # Esri sample WFS wfs_layers(wfs_example_url("esri_sample")) ## End(Not run)## Not run: # Tasmania LIST WFS wfs_layers(wfs_example_url("list_tasmania")) # Esri sample WFS wfs_layers(wfs_example_url("esri_sample")) ## End(Not run)
Fetches vector features from a WFS, OGC API Features, or ArcGIS REST
endpoint and returns a tibble with a wk::wkb geometry column.
wfs_read( base_url, layer, bbox = NULL, max_features = 100, where = NULL, driver = "auto", version = NULL, srs = NULL, convert_linear = TRUE, promote_to_multi = FALSE )wfs_read( base_url, layer, bbox = NULL, max_features = 100, where = NULL, driver = "auto", version = NULL, srs = NULL, convert_linear = TRUE, promote_to_multi = FALSE )
base_url |
Character. The service endpoint URL. |
layer |
Character. Layer name to read. Use |
bbox |
Numeric vector of length 4 ( |
max_features |
Integer or |
where |
Character or |
driver |
Character. Driver hint; see |
version |
Character or |
srs |
Character or |
convert_linear |
Logical. If |
promote_to_multi |
Logical. If |
A tibble::tibble with attribute columns and a geometry
column of class wk::wkb.
## Not run: # Tasmania LIST: cadastral parcels in Sandy Bay parcels <- wfs_read( wfs_example_url("list_tasmania"), layer = "Public_OpenDataWFS:LIST_Cadastral_Parcels", bbox = wfs_example_bbox("sandy_bay"), srs = "EPSG:28355", max_features = 100 ) parcels wk::wk_plot(parcels$geometry) # Esri sample world cities cities <- wfs_read( wfs_example_url("esri_sample"), layer = "esri:cities" ) ## End(Not run)## Not run: # Tasmania LIST: cadastral parcels in Sandy Bay parcels <- wfs_read( wfs_example_url("list_tasmania"), layer = "Public_OpenDataWFS:LIST_Cadastral_Parcels", bbox = wfs_example_bbox("sandy_bay"), srs = "EPSG:28355", max_features = 100 ) parcels wk::wk_plot(parcels$geometry) # Esri sample world cities cities <- wfs_read( wfs_example_url("esri_sample"), layer = "esri:cities" ) ## End(Not run)
Returns a tibble of known, tested public services that work with readwfs. This isn't exhaustive – it's a starting point. If you find a good one, open an issue.
wfs_services()wfs_services()
A tibble::tibble with columns: name, url, driver,
region, description, srs, notes.
wfs_services() # Try one ## Not run: svc <- wfs_services() wfs_layers(svc$url[1]) ## End(Not run)wfs_services() # Try one ## Not run: svc <- wfs_services() wfs_layers(svc$url[1]) ## End(Not run)