| catr_wms_get_layer | R Documentation |
Retrieve georeferenced map images from the Spanish Cadastre WMS service.
This function wraps mapSpain::esp_get_tiles().
catr_wms_get_layer(
x,
srs = NULL,
what = c("building", "buildingpart", "parcel", "zoning", "address", "admboundary",
"admunit"),
styles = "default",
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE,
crop = FALSE,
options = NULL,
...
)
x |
Input defining the query area. See Bounding box. It can be:
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
what |
WMS layer to download. See Layers and styles. |
styles |
Style to apply to the selected WMS layer. See Layers and styles. |
update_cache |
Logical. Whether to refresh the cached file. Defaults to
|
cache_dir |
Path to a cache directory. If |
verbose |
Logical. Whether to display informational messages. |
crop |
Logical. If |
options |
A named list containing additional options to pass to the query. |
... |
Arguments passed on to
|
A SpatRaster with three RGB or four RGBA layers. See
terra::RGB().
When x is a numeric vector, make sure that srs matches the coordinate
values. When x is an sf object, the srs value is
ignored.
The query uses EPSG:3857 (Web Mercator), then
transforms the tile back to the SRS of x. If the tile appears distorted,
provide a spatial object as x or set srs to the SRS of the requested
tile. See Examples.
The what argument selects one of the following API layers:
"parcel": CP.CadastralParcel.
"zoning": CP.CadastralZoning.
"building": BU.Building.
"buildingpart": BU.BuildingPart.
"address": AD.Address.
"admboundary": AU.AdministrativeBoundary.
"admunit": AU.AdministrativeUnit.
The WMS service provides different styles for each layer (what argument).
Available styles include:
"parcel": "BoundariesOnly", "ReferencePointOnly" and
"ELFCadastre".
"zoning": "BoundariesOnly" and "ELFCadastre".
"building" and "buildingpart": "ELFCadastre".
"address": "Number.ELFCadastre".
"admboundary" and "admunit": "ELFCadastre".
See the API documentation for complete layer and style information.
catr_wfs_get_address_bbox(), catr_wfs_get_buildings_bbox() and
catr_wfs_get_parcels_bbox() retrieve vector geometries that can define
the map extent through x.
mapSpain::esp_get_tiles() downloads map tiles.
terra::RGB() identifies RGB channels.
terra::plotRGB() and tidyterra::geom_spatraster_rgb() plot RGB
rasters.
if (requireNamespace("tidyterra", quietly = TRUE)) {
# With a bounding box
pict <- catr_wms_get_layer(
c(222500, 4019500, 223700, 4020700),
srs = 25830,
what = "parcel"
)
library(mapSpain)
library(ggplot2)
library(tidyterra)
ggplot() +
geom_spatraster_rgb(data = pict)
# With a spatial object
parcels <- catr_wfs_get_parcels_neigh_parcel("3662303TF3136B", srs = 25830)
# Use styles
parcels_img <- catr_wms_get_layer(parcels,
what = "buildingpart",
srs = 25830, # Same as the parcels object
bbox_expand = 0.3,
styles = "ELFCadastre"
)
ggplot() +
geom_sf(data = parcels, fill = "blue", alpha = 0.5) +
geom_spatraster_rgb(data = parcels_img)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.