Skip to contents

This function interfaces the wfs_clc5_* products of the BKG.

Usage

bkg_clc(
  ...,
  year = "2018",
  bbox = NULL,
  poly = NULL,
  predicate = "intersects",
  filter = NULL,
  epsg = 3035,
  properties = NULL,
  max = NULL
)

Arguments

...

Used to construct CQL filters. Dot arguments accept an R-like syntax that is converted to CQL queries internally. These queries basically consist of a property name on the left, an aribtrary vector on the right, and an operator that links both sides. If multiple queries are provided, they will be chained with AND. The following operators and their respective equivalents in CQL and XML are supported:

RCQLXML
===PropertyIsEqualTo
!=<>PropertyIsNotEqualTo
<<PropertyIsLessThan
>>PropertyIsGreaterThan
>=>=PropertyIsGreaterThanOrEqualTo
<=<=PropertyIsLessThanOrEqualTo
%LIKE%LIKEPropertyIsLike
%ILIKE%ILIKE
%in%IN

To construct more complex queries, you can use the filter argument to pass CQL queries directly. Also note that you can switch between CQL and XML queries using options(ffm_query_language = "xml"). See also wfs_filter.

year

Version year of the dataset. You can use latest to retrieve the latest dataset version available on the BKG's geodata center. Older versions can be browsed using the archive.

bbox

An sf geometry or a boundary box vector of the format c(xmin, ymin, xmax, ymax). Used as a geometric filter to include only those geometries that relate to bbox according to the predicate specified in predicate. If an sf geometry is provided, coordinates are automatically transformed to ESPG:25832 (the default CRS), otherwise they are expected to be in EPSG:25832.

poly

An sf geometry. Used as a geometric filter to include only those geometries that relate to poly according to the predicate specified in predicate. Coordinates are automatically transformed to ESPG:25832 (the default CRS).

predicate

A spatial predicate that is used to relate the output geometries with the object specified in bbox or poly. For example, if predicate = "within", and bbox is specified, returns only those geometries that lie within bbox. Can be one of "equals", "disjoint", "intersects", "touches", "crosses", "within", "contains", "overlaps", "relate", "dwithin", or "beyond". Defaults to "intersects".

filter

A character string containing a valid CQL or XML filter. This string is appended to the query constructed through .... Use this argument to construct more complex filters. Defaults to NULL.

epsg

An EPSG code specifying a coordinate reference system of the output. If you're unsure what this means, try running sf::st_crs(...)$epsg on a spatial object that you are working with. Defaults to 3035.

properties

Vector of columns to include in the output.

max

Maximum number of results to return.

Value

An sf dataframe with polygon geometries and the following columns:

  • clc*: CLC land cover classes for the given year. An overview of all CLC classes can be found in the Copernicus documentation.

  • shape_length: Circumference of the polygon in meters

  • shape_area: Area of the polygon in square meters

Query language

By default, WFS requests use CQL (Contextual Query Language) queries for simplicity. CQL queries only work together with GET requests. This means that when the URL is longer than 2048 characters, they fail. While POST requests are much more flexible and able to accommodate long queries, XML is really a pain to work with and I'm not confident in my approach to construct XML queries. You can control whether to send GET or POST requests by setting options(ffm_query_language = "XML") or options(ffm_query_language = "CQL").

Examples

if (FALSE) { # getFromNamespace("ffm_run_examples", ns = "ffm")()
# Get glaciers in Germany
bkg_clc(clc18 == "335")

# Get all coastal wetlands
bkg_clc(clc18 %LIKE% "42%")

# Get only wetlands in Lower Saxony
rlang::local_options(ffm_query_language = "xml")
lowsax <- bkg_admin(level = "lan", scale = "5000", sn_l == "03", gf == 9)
wetlands <- bkg_clc(clc18 %LIKE% "4%", poly = lowsax)
plot(lowsax$geometry)
plot(wetlands$geometry, add = TRUE)
}