Improves on the v1 importer in four ways: the protocol version is taken from the negotiated capabilities rather than hard-coded, large layers are fetched page by page instead of in one request that times out, a spatial or attribute filter can be pushed down to the server, and if the endpoint cannot produce GeoJSON the request falls back to GML.
Usage
argentum_read_wfs(
x,
layer,
bbox = NULL,
crs = NULL,
max_features = NULL,
page_size = arg_opt("argentum.page_size"),
filter = NULL,
quiet = arg_opt("argentum.quiet")
)Arguments
- x
An organization name from
argentum_organizations(), or a WFS URL.- layer
Layer (feature type) name, as reported by
argentum_layers().- bbox
Optional spatial filter. Either a numeric vector
c(xmin, ymin, xmax, ymax), or any object accepted bysf::st_bbox(), such as an existingsfobject.- crs
Coordinate reference system to request, e.g.
"EPSG:4326"or4326.NULL(default) negotiates one from the layer's declared list, preferringEPSG:4326; if the layer declares none, the server's own default is used.- max_features
Stop after this many features.
NULL(default) reads everything.- page_size
Features per request. Defaults to
getOption("argentum.page_size"). Set toInfto disable paging for servers that mishandlestartIndex.- filter
A CQL filter pushed to the server, e.g.
"provincia = 'Mendoza'". Supported by GeoServer; ignored by some ArcGIS deployments.- quiet
Suppress progress messages.
Details
When a read fails outright the request is retried with paging disabled and then against each older protocol version, exactly as the ArgentinaGeoServices QGIS plugin does: several Argentine GeoServer installs advertise 2.0.0 and then fail to serialise GML in that version while answering 1.0.0 perfectly. If every attempt fails, the server is asked for a single feature so that its own error message can be reported instead of a bare parse failure.
See also
argentum_download() to write layers straight to disk.
Examples
# \donttest{
url <- "https://wms.ign.gob.ar/geoserver/ows"
# Everything in a small layer
provinces <- argentum_read_wfs(url, "ign:provincia")
#> ℹ Reading ign:provincia (page 1)
#> ✔ Reading ign:provincia (page 2) [2m 2.9s]
#>
#> ✔ Read 24 features from ign:provincia.
# Only what falls inside a bounding box, reprojected
argentum_read_wfs(
url, "ign:provincia",
bbox = c(-59, -35, -57, -34),
crs = 4326
)
#> ℹ Reading ign:provincia (page 1)
#> ✔ Reading ign:provincia (page 2) [9.5s]
#>
#> ✔ Read 3 features from ign:provincia.
#> Simple feature collection with 3 features and 9 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -63.38594 ymin: -41.03791 xmax: -56.66499 ymax: -30.15897
#> Geodetic CRS: WGS 84
#> id gid entidad fna gna
#> 1 provincia.54 54 0 Ciudad Autónoma de Buenos Aires Ciudad Autónoma
#> 2 provincia.68 68 0 Provincia de Buenos Aires Provincia
#> 3 provincia.70 70 0 Provincia de Entre Ríos Provincia
#> nam in1 fdc sag
#> 1 Ciudad Autónoma de Buenos Aires 02 Geografía IGN
#> 2 Buenos Aires 06 Geografía IGN
#> 3 Entre Ríos 30 Geografía IGN
#> geometry
#> 1 MULTIPOLYGON (((-58.45535 -...
#> 2 MULTIPOLYGON (((-60.24091 -...
#> 3 MULTIPOLYGON (((-58.58534 -...
# }
