CatastRo is a package that provides access to different API services of the Spanish Cadastre. With CatastRo, you can download spatial objects such as buildings, cadastral parcels and maps, and geocode cadastral references.
Installation
Install CatastRo from CRAN:
install.packages("CatastRo")The SSL certificate of the Spanish Cadastre presents some issues that may cause an error when using CatastRo (especially on macOS, see issue #40):
In CatastRo >= 1.0.0, you can try to fix it by running this line in your session right after loading the package:
# Disable SSL verification
options(catastro_ssl_verify = 0)If you wish to make this setup persistent, write the same code in your .Rprofile:
.Rprofile
# ... other options...
options(catastro_ssl_verify = 0)Package API
The functions of CatastRo are organized by API endpoint. The package naming convention is catr_*api*_*description*.
OVCCoordenadas
These functions allow geocoding and reverse geocoding of cadastral references using the OVCCoordenadas service.
These functions are named catr_ovc_get_* and return a tibble, as provided by the tibble package. See vignette("ovcservice", package = "CatastRo") for a detailed description of these functions.
INSPIRE
These functions return spatial objects in the formats provided by the sf or terra packages using the Catastro INSPIRE service.
Note that the coverage of this service is 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 one querying a different service:
ATOM service
The ATOM service allows batch downloading vector objects of different cadastral elements for a specific municipality. The result is provided as sf objects (see the sf package).
These functions are named catr_atom_get_xxx.
WFS service
The WFS service allows downloading vector objects of specific cadastral elements. The results are provided as sf objects (see the sf package). Note that there are restrictions on the extent and number of elements that can be queried. For batch downloading, the ATOM service is preferred.
These functions are named catr_wfs_get_xxx.
WMS service
This service allows downloading georeferenced images of different cadastral elements. The results are provided as rasters in the format provided by the terra package.
There is a single function for querying this service: catr_wms_get_layer().
Terms and conditions of use
Please check the service’s downloading provisions.
Examples
This script highlights some features of CatastRo:
Geocode a cadastral reference
library(CatastRo)
catr_ovc_get_cpmrc(rc = "13077A01800039")
#> # A tibble: 1 × 10
#> xcoord ycoord refcat address pc.pc1 pc.pc2 geo.xcen geo.ycen geo.srs ldt
#> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 -3.46 38.6 13077A018… DS DIS… 13077… 18000… -3.4575… 38.6184… EPSG:4… DS D…Extract a cadastral reference from a given set of coordinates
catr_ovc_get_rccoor(
lat = 38.6196566583596,
lon = -3.45624183836806,
srs = "4230"
)
#> # A tibble: 1 × 8
#> refcat address pc.pc1 pc.pc2 geo.xcen geo.ycen geo.srs ldt
#> <chr> <chr> <chr> <chr> <dbl> <dbl> <chr> <chr>
#> 1 13077A01800039 DS DISEMINADO P… 13077… 18000… -3.46 38.6 EPSG:4… DS D…Extract geometries using the ATOM service
bu <- catr_atom_get_buildings("Nava de la Asuncion", to = "Segovia")
# Map.
library(ggplot2)
ggplot(bu) +
geom_sf(aes(fill = currentUse), col = NA) +
coord_sf(
xlim = c(374500, 375500),
ylim = c(4556500, 4557500)
) +
scale_fill_manual(values = hcl.colors(6, "Dark 3")) +
theme_minimal() +
labs(title = "Nava de la Asunción, Segovia")
Extract geometries using the WFS service
wfs_get_buildings <- catr_wfs_get_buildings_bbox(
c(-4.134, 40.952, -4.131, 40.953),
srs = 4326
)
# Map.
ggplot(wfs_get_buildings) +
geom_sf() +
labs(title = "Alcázar of Segovia, Segovia, Spain")
A note on caching
Some datasets and tiles may exceed 50 MB. You can set a local cache directory using the following function:
catr_set_cache_dir("./path/to/location")When this option is set, CatastRo will look for cached files and load them, speeding up the process.
Citation
Delgado Panadero Á, Hernangómez D (2026). CatastRo: Interface to the API Sede Electrónica Del Catastro. doi:10.32614/CRAN.package.CatastRo. https://ropenspain.github.io/CatastRo/.
A BibTeX entry for LaTeX users is:
@Manual{R-CatastRo,
title = {{CatastRo}: Interface to the {API} Sede Electrónica Del Catastro},
author = {Ángel {Delgado Panadero} and Diego Hernangómez},
doi = {10.32614/CRAN.package.CatastRo},
year = {2026},
version = {1.0.1},
url = {https://ropenspain.github.io/CatastRo/},
abstract = {Access public spatial data from the Spanish Cadastre through its INSPIRE and cadastral web services. Provides tools to download cadastral parcels, buildings, addresses and map images, and to geocode cadastral references.},
}Contribute
Check the GitHub page for the source code.
