emodnet_get_layers: Get EMODnet WFS datasets (layers)

View source: R/layers.R

emodnet_get_layersR Documentation

Get EMODnet WFS datasets (layers)

Description

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,
  simplify = FALSE,
  reduce_layers = deprecated(),
  ...
)

Arguments

wfs

A WFSClient R6 object with methods for interfacing an OGC Web Feature Service. From emodnet_init_wfs_client().

service

the EMODnet OGC WFS service name. For available services, see emodnet_wfs().

service_version

[Deprecated] the WFS service version. Now always "2.0.0".

layers

a character vector of layer names. To get info on layers, including layer_name use emodnet_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 ignored

  • named 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.

simplify

whether to reduce output layers to a single sf object. This only works if the column names are the same.

reduce_layers

[Deprecated] use simplify.

...

additional vendor parameter arguments passed to ows4R::GetFeature(). For example, including count = 1 returns the first available feature. Or outputFormat = "CSV" (or outputFormat = "JSON") might help downloading bigger datasets.

Value

If simplify = FALSE (default), a list of sf objects, one element for each layer. Any layers for which download was unsuccessful will be NULL. If simplify = TRUE, all layers are reduced (if possible: if all column names are the same) to a single sf containing data for all layers. NULL layers are ignored. simplify = 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:

Examples


# 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"]])


EMODnet/EMODnetWFS documentation built on June 14, 2025, 2:16 p.m.