| inspire | R Documentation |
Given pairs of coordinates, generates their INSPIRE grid representation. Given INSPIRE identifiers, can also extract the X and Y coordinates.
An INSPIRE ID contains information about the CRS, cell size and the ETRS89-LAEA coordinates of the south-west corner of the grid cell in its format.
CRS3035RES{cellsize}mN{y}E{x} # long format
{cellsize}N{y}E{x} # short format
The short format always uses meters while the short formats aggregates cell sizes greater or equal to 1000m to km.
z22_inspire_generate(coords, res = NULL, short = FALSE, llc = FALSE)
z22_inspire_extract(inspire, as = c("df", "sf"), meta = FALSE)
coords |
A list, matrix, or dataframe where the X and Y coordinates are
either in the columns Can also be a |
res |
Resolution of the grid. Can be |
short |
If |
llc |
Do the coordinates in |
inspire |
A vector of INSPIRE IDs. Can be either short or long format. |
as |
Specifies the output class. Must be one of |
meta |
Whether to include parsed CRS and resolution in the output.
If |
To remain fast even for huge grid datasets, the function is just a very
simple sprintf wrapper that performs no input checks. To
produce valid INSPIRE identifiers, make sure to transform your data to
ETRS89-LAEA (e.g. using
st_transform(..., 3035)). You should also
make sure that the coordinates are the south-west corner of existing
INSPIRE grid cells.
z22_inspire_generate returns a character vector containing
the INSPIRE identifiers. z22_inspire_extract returns a dataframe
or sfc object containing the points extracted from
the INSPIRE identifiers. Note that the returned coordinates are always
the centers of the grid cells as opposed to the south-west corners.
library(dplyr, warn.conflicts = FALSE)
# Generate IDs from a dataframe
coords <- tibble(x = c(4334150, 4334250), y = c(2684050, 2684050))
identical(z22_inspire_extract(z22_inspire_generate(coords))[c("x", "y")], coords)
# Extract coordinates from short ID strings
z22_inspire_extract("100mN34000E44000")
# Generate IDs from an sf dataframe
if (requireNamespace("sf", quietly = TRUE)) {
coords <- sf::st_as_sf(coords, coords = c("x", "y"), crs = 3035)
z22_inspire_generate(coords)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.