CatastRo provides access to services from the Spanish Cadastre. With CatastRo, you can download official address, cadastral parcel, building and map data.
The OVCCoordenadas service retrieves the coordinates of a known cadastral reference (geocoding). It is also possible to retrieve the cadastral references around a specific pair of coordinates (reverse geocoding). CatastRo returns the results as a tibble. This functionality is described in detail in the corresponding vignette (see vignette("ovcservice", package = "CatastRo")).
The INSPIRE Directive aims to create a European Union Spatial Data Infrastructure (SDI) for the purposes of EU environmental policies and policies or activities which may have an impact on the environment. This European Spatial Data Infrastructure enables the sharing of environmental spatial information among public sector organizations, facilitates public access to spatial information across Europe and assist in policy-making across boundaries.
The implementation of the INSPIRE directive in the Spanish Cadastre (see Spanish Cadastre INSPIRE) allows retrieval of spatial objects from the cadastral database:
sf objects, using the sf package.SpatRaster objects, using the terra package.Note that these services cover 95% of the Spanish territory, excluding the Basque Country and Navarre1, which have their own independent cadastral offices.
There are three types of functions, each querying a different service:
ATOM service: The ATOM service downloads complete municipal datasets for different cadastral elements.
WFS service: The WFS service downloads vector objects for specific cadastral elements. Note that there are restrictions on the extent and number of elements that can be queried. For full municipal downloads, prefer the ATOM service.
WMS service: The WMS service downloads georeferenced map images for different cadastral elements.
This example demonstrates some of the main capabilities of the package by recreating a cadastral map of the surroundings of the Santiago Bernabéu Stadium. We use the WMS and WFS services to retrieve different layers.
# Extract buildings by bounding box.
# Check https://boundingbox.klokantech.com/
library(CatastRo)
stadium <- catr_wfs_get_buildings_bbox(
c(-3.6891446916, 40.4523311971, -3.687462138, 40.4538643165),
srs = 4326
)
# Extract cadastral parcels using spatial objects in the query.
stadium_parcel <- catr_wfs_get_parcels_bbox(stadium)
# Project for tiles.
stadium_parcel_pr <- sf::st_transform(stadium_parcel, 25830)
# Extract parcel label imagery.
labs <- catr_wms_get_layer(
stadium_parcel_pr,
what = "parcel",
styles = "BoundariesOnly",
srs = 25830
)
# Plot.
library(ggplot2)
library(tidyterra) # For terra tiles.
ggplot() +
geom_spatraster_rgb(data = labs) +
geom_sf(
data = stadium_parcel_pr,
fill = NA, col = "red", linewidth = 2
) +
geom_sf(data = stadium, fill = "red", alpha = .5) +
coord_sf(crs = 25830)Figure 1: Santiago Bernabéu example
We can also create thematic maps using the information available on the spatial objects. We produce a visualization of the urban growth of Granada using CatastRo, replicating the map produced by Dominic Royé (Royé 2019), using the ATOM service.
First, we extract the coordinates of Granada’s city center with mapSpain:
library(dplyr)
library(sf)
library(mapSpain)
# Use mapSpain to get the coordinates.
city <- esp_get_capimun(munic = "^Granada$")The next step is to extract the buildings using the ATOM service. We also use catr_get_code_from_coords() to identify Granada’s code in the Cadastre and download the buildings with catr_atom_get_buildings().
city_catr_code <- catr_get_code_from_coords(city)
city_catr_code
#> # A tibble: 1 × 12
#> munic catr_to catr_munic catrcode cpro cmun inecode nm cd cmc cp
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 GRANADA 18 900 18900 18 087 18087 GRANA… 18 900 18
#> # ℹ 1 more variable: cm <chr>
city_bu <- catr_atom_get_buildings(city_catr_code$catrcode)Next, we limit the analysis to a circle with a radius of 1.5 km around the city center:
buff <- city |>
# Adjust CRS to 25830 for buildings.
st_transform(st_crs(city_bu)) |>
# Buffer.
st_buffer(1500)
# Cut buildings.
dataviz <- st_intersection(city_bu, buff)
ggplot(dataviz) +
geom_sf()Figure 2: Minimal cadastral map of Granada
Now let’s extract the construction year, available in the column beginning:
# Extract the first four positions.
year <- substr(dataviz$beginning, 1, 4)
# Replace entries that do not look like numbers with 0000.
year[!(year %in% 0:2500)] <- "0000"
# Convert to numeric.
year <- as.integer(year)
# Add a new column.
dataviz <- dataviz |>
mutate(year = year)The last step is to group the data by construction year and create the visualization. Here, cut() creates classes for each decade from 1900 onward:
dataviz <- dataviz |>
mutate(
year_cat = cut(year, breaks = c(0, seq(1900, 2030, by = 10)), dig.lab = 4)
)
ggplot(dataviz) +
geom_sf(aes(fill = year_cat), color = NA, na.rm = TRUE) +
scale_fill_manual(
values = hcl.colors(15, "Spectral"),
na.translate = FALSE
) +
theme_void() +
labs(title = "GRANADA", fill = "") +
theme(
panel.background = element_rect(fill = "black"),
plot.background = element_rect(fill = "black"),
legend.justification = .5,
legend.text = element_text(
colour = "white",
size = 12
),
plot.title = element_text(
colour = "white",
hjust = .5,
margin = margin(t = 30),
size = 30
),
plot.caption = element_text(
colour = "white",
margin = margin(b = 20),
hjust = .5
),
plot.margin = margin(r = 40, l = 40)
)Figure 2: Granada - Urban growth
The package CatastRoNav provides access to the Cadastre of Navarre, with similar functionality to CatastRo.↩︎