Performs an WFS getFeature request for layers from a wfs
object or
specified EMODnet Service. Filtering
of layer features can also be handled via ECQL language filters.
Usage
emodnet_get_layers(
wfs = NULL,
service = NULL,
service_version = NULL,
layers,
crs = NULL,
cql_filter = NULL,
reduce_layers = FALSE,
...
)
Arguments
- wfs
A
WFSClient
R6 object with methods for interfacing an OGC Web Feature Service.- service
the EMODnet OGC WFS service name. For available services, see
emodnet_wfs()
.- service_version
- layers
a character vector of layer names. To get info on layers, including
layer_name
useemodnet_get_wfs_info()
.- crs
integer. EPSG code for the output crs. If
NULL
(default), layers are returned with original crs.- cql_filter
character. Features returned can be filtered using valid Extended Common Query Language (ECQL) filtering statements (https://docs.geoserver.org/stable/en/user/filter/ecql_reference.html). Should be one of:
character string or character vector of length 1. Filter will be recycled across all layers requested.
character vector of length equal to the length of layers. Filter will be matched to layers sequentially. Elements containing
NA
are ignorednamed character vector. Each filter will be applied to the layer corresponding to the filter name. Filters with names that do not correspond to any layers are ignored. Layers without corresponding filters are returned whole.
- reduce_layers
whether to reduce output layers to a single
sf
object.- ...
additional vendor parameter arguments passed to
ows4R::GetFeature()
. For example, includingcount = 1
returns the first available feature. OroutputFormat = "CSV"
(oroutputFormat = "JSON"
) might help downloading bigger datasets.
Value
If reduce_layers = FALSE
(default), a list of sf
objects, one element for each layer. Any layers for which download was
unsuccessful will be NULL. If reduce_layers = TRUE
, all layers are
reduced (if possible) to a single sf
containing data for all layers.
NULL
layers are ignored. reduce_layers = TRUE
can also be used to return
an sf
out of a single layer request instead of a list of length 1.
Big downloads
If a layer is really big (like "abiotic_observations"
of the
"biology_occurrence_data"
service),
you might consider a combination of these ideas:
using
outputFormat = "CSV"
;filtering using
cql_filters
or bounding boxes (possibly splitting the area of interests into several requests);Using EMODnet's download toolbox.
Examples
if (FALSE) { # interactive()
# Layers as character vector
emodnet_get_layers(
service = "biology",
layers = c("mediseh_zostera_m_pnt", "mediseh_posidonia_nodata")
)
# Usage of cql_filter
emodnet_get_layers(
service = "biology",
layers = "mediseh_zostera_m_pnt",
cql_filter = "country = 'Francia'"
)
# Usage of vendor parameter
emodnet_get_layers(
service = "biology",
layers = "mediseh_zostera_m_pnt",
count = 1
)
# Usage of csv output
data <- emodnet_get_layers(
service = "biology_occurrence_data",
layers = "abiotic_observations",
outputFormat = "CSV"
)
str(data[["abiotic_observations"]])
}