| Title: | Interface to the Spanish 'Catastro' Web Services |
| Version: | 1.0.2 |
| Description: | Access public spatial data from the Spanish 'Catastro' through its 'INSPIRE' and related web services. Retrieve parcel, building, address and map image data, and convert between parcel references and coordinates. |
| License: | GPL-2 |
| URL: | https://ropenspain.github.io/CatastRo/, https://github.com/rOpenSpain/CatastRo |
| BugReports: | https://github.com/rOpenSpain/CatastRo/issues |
| Depends: | R (≥ 4.1.0) |
| Imports: | cli, dplyr, httr2 (≥ 1.0.0), lifecycle, mapSpain (≥ 1.0.0), rappdirs (≥ 0.3.0), sf (≥ 1.0.0), terra, tibble, tools, utils, xml2 |
| Suggests: | ggplot2, knitr, quarto, testthat (≥ 3.0.0), tidyterra, withr |
| VignetteBuilder: | quarto |
| Config/Needs/website: | ropenspain/rostemplate, devtools, sessioninfo, remotes, sfheaders, rapidjsonr, jsonify, geometries, magick |
| Config/roxygen2/markdown: | TRUE |
| Config/roxygen2/version: | 8.0.0 |
| Config/testthat/edition: | 3 |
| Config/testthat/parallel: | true |
| Copyright: | © Dirección General del Catastro <https://www.catastro.meh.es/> |
| Encoding: | UTF-8 |
| LazyData: | true |
| X-schema.org-isPartOf: | https://ropenspain.es/ |
| X-schema.org-keywords: | catastro, cran, cran-r, gis, maps, r, r-package, ropenspain, rstats, spain, spatial, static-tiles |
| NeedsCompilation: | no |
| Packaged: | 2026-06-03 19:01:18 UTC; diego |
| Author: | Ángel Delgado Panadero
|
| Maintainer: | Diego Hernangómez <diego.hernangomezherrero@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-06-03 19:10:02 UTC |
CatastRo: Interface to the Spanish 'Catastro' Web Services
Description
Access public spatial data from the Spanish 'Catastro' through its 'INSPIRE' and related web services. Retrieve parcel, building, address and map image data, and convert between parcel references and coordinates.
Author(s)
Maintainer: Diego Hernangómez diego.hernangomezherrero@gmail.com (ORCID)
Authors:
Diego Hernangómez diego.hernangomezherrero@gmail.com (ORCID)
Ángel Delgado Panadero delgadopanadero@gmail.com (ORCID) [copyright holder]
Other contributors:
Iñaki Ucar (ORCID) [contributor]
See Also
Useful links:
Report bugs at https://github.com/rOpenSpain/CatastRo/issues
ATOM INSPIRE: download all addresses of a municipality
Description
Retrieve the spatial data of all addresses belonging to a single municipality
using the ATOM INSPIRE service. This function also returns corresponding
street information in fields prefixed with tfname_*.
Usage
catr_atom_get_address(
munic,
to = NULL,
cache = deprecated(),
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
Arguments
munic |
Municipality to extract, can be part of a string or a
cadastral code. See |
to |
Optional argument for defining the territorial office to which
|
cache |
|
update_cache |
Logical. Should the cached file be refreshed? Defaults to
|
cache_dir |
Path to a cache directory. On |
verbose |
Logical. If |
Value
A sf object.
References
INSPIRE services for cadastral cartography.
See Also
Related INSPIRE API functions:
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer(),
inspire_wfs_get()
Related ATOM INSPIRE functions:
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_atom_search_munic()
Other addresses:
catr_atom_get_address_db_all(),
catr_wfs_get_address_bbox()
Other spatial:
catr_atom_get_buildings(),
catr_atom_get_parcels(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer()
Examples
s <- catr_atom_get_address("Melque", to = "Segovia")
library(ggplot2)
ggplot(s) +
geom_sf(aes(color = specification)) +
coord_sf(
xlim = c(376200, 376850),
ylim = c(4545000, 4546000)
) +
labs(
title = "Addresses",
subtitle = "Melque de Cercos, Segovia"
)
ATOM INSPIRE: reference database for ATOM addresses
Description
Create a database containing the URLs provided in the ATOM INSPIRE service of the Spanish Cadastre for extracting addresses.
catr_atom_get_address_db_all() provides a top-level table with all
territorial offices, except the Basque Country and Navarre, and the
municipalities included in each office. catr_atom_get_address_db_to()
provides a table for one territorial office and its municipalities.
Usage
catr_atom_get_address_db_all(
cache = deprecated(),
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
catr_atom_get_address_db_to(
to,
cache = deprecated(),
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
Arguments
cache |
|
update_cache |
Logical. Should the cached file be refreshed? Defaults to
|
cache_dir |
Path to a cache directory. On |
verbose |
Logical. If |
to |
Character. Territorial office. Internally uses |
Value
A tibble with the information requested with the following fields:
-
territorial_office: Territorial office, corresponding to each province of Spain except the Basque Country and Navarre. -
url: ATOM URL for the corresponding territorial office. -
munic: Name of the municipality. -
date: Reference date of the data. The information from this service is updated twice a year.
Source
https://www.catastro.hacienda.gob.es/INSPIRE/Addresses/ES.SDGC.AD.atom.xml
See Also
Related INSPIRE API functions:
catr_atom_get_address(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer(),
inspire_wfs_get()
Related ATOM INSPIRE functions:
catr_atom_get_address(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_atom_search_munic()
Other addresses:
catr_atom_get_address(),
catr_wfs_get_address_bbox()
Other databases:
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels_db_all(),
catr_atom_search_munic(),
catr_srs_values
Examples
catr_atom_get_address_db_all()
ATOM INSPIRE: download all buildings of a municipality
Description
Retrieve the spatial data of all buildings belonging to a single municipality using the ATOM INSPIRE service.
Usage
catr_atom_get_buildings(
munic,
to = NULL,
what = c("building", "buildingpart", "other"),
cache = deprecated(),
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
Arguments
munic |
Municipality to extract, can be part of a string or a
cadastral code. See |
to |
Optional argument for defining the territorial office to which
|
what |
Information to load. Options are:
|
cache |
|
update_cache |
Logical. Should the cached file be refreshed? Defaults to
|
cache_dir |
Path to a cache directory. On |
verbose |
Logical. If |
Value
A sf object.
References
INSPIRE services for cadastral cartography.
See Also
Related INSPIRE API functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer(),
inspire_wfs_get()
Related ATOM INSPIRE functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_atom_search_munic()
Other buildings:
catr_atom_get_buildings_db_all(),
catr_wfs_get_buildings_bbox()
Other spatial:
catr_atom_get_address(),
catr_atom_get_parcels(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer()
Examples
s <- catr_atom_get_buildings("Nava de la Asuncion", to = "Segovia")
library(ggplot2)
ggplot(s) +
geom_sf() +
coord_sf(
xlim = c(374500, 375500),
ylim = c(4556500, 4557500)
) +
labs(
title = "Buildings",
subtitle = "Nava de la Asuncion, Segovia"
)
ATOM INSPIRE: reference database for ATOM buildings
Description
Create a database containing the URLs provided in the ATOM INSPIRE service of the Spanish Cadastre for extracting buildings.
catr_atom_get_buildings_db_all() provides a top-level table with all
territorial offices, except the Basque Country and Navarre, and the
municipalities included in each office. catr_atom_get_buildings_db_to()
provides a table for one territorial office and its municipalities.
Usage
catr_atom_get_buildings_db_all(
cache = deprecated(),
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
catr_atom_get_buildings_db_to(
to,
cache = deprecated(),
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
Arguments
cache |
|
update_cache |
Logical. Should the cached file be refreshed? Defaults to
|
cache_dir |
Path to a cache directory. On |
verbose |
Logical. If |
to |
Character. Territorial office. Internally uses |
Value
A tibble with the information requested with the following fields:
-
territorial_office: Territorial office, corresponding to each province of Spain except the Basque Country and Navarre. -
url: ATOM URL for the corresponding territorial office. -
munic: Name of the municipality. -
date: Reference date of the data. The information from this service is updated twice a year.
Source
https://www.catastro.hacienda.gob.es/INSPIRE/buildings/ES.SDGC.BU.atom.xml
See Also
Related INSPIRE API functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer(),
inspire_wfs_get()
Related ATOM INSPIRE functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_atom_search_munic()
Other buildings:
catr_atom_get_buildings(),
catr_wfs_get_buildings_bbox()
Other databases:
catr_atom_get_address_db_all(),
catr_atom_get_parcels_db_all(),
catr_atom_search_munic(),
catr_srs_values
Examples
catr_atom_get_buildings_db_all()
ATOM INSPIRE: download all cadastral parcels of a municipality
Description
Retrieve the spatial data of all cadastral parcels belonging to a single municipality using the ATOM INSPIRE service.
Usage
catr_atom_get_parcels(
munic,
to = NULL,
what = c("parcel", "zoning"),
cache = deprecated(),
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
Arguments
munic |
Municipality to extract, can be part of a string or a
cadastral code. See |
to |
Optional argument for defining the territorial office to which
|
what |
Information to load. Options are:
|
cache |
|
update_cache |
Logical. Should the cached file be refreshed? Defaults to
|
cache_dir |
Path to a cache directory. On |
verbose |
Logical. If |
Value
A sf object.
References
INSPIRE services for cadastral cartography.
See Also
Related INSPIRE API functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels_db_all(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer(),
inspire_wfs_get()
Related ATOM INSPIRE functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels_db_all(),
catr_atom_search_munic()
Other parcels:
catr_atom_get_parcels_db_all(),
catr_wfs_get_parcels_bbox()
Other spatial:
catr_atom_get_address(),
catr_atom_get_buildings(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer()
Examples
s <- catr_atom_get_parcels("Melque", to = "Segovia", what = "parcel")
library(ggplot2)
ggplot(s) +
geom_sf() +
labs(
title = "Cadastral parcels",
subtitle = "Melque de Cercos, Segovia"
)
ATOM INSPIRE: reference database for ATOM cadastral parcels
Description
Create a database containing the URLs provided in the ATOM INSPIRE service of the Spanish Cadastre for extracting cadastral parcels.
catr_atom_get_parcels_db_all() provides a top-level table with all
territorial offices, except the Basque Country and Navarre, and the
municipalities included in each office. catr_atom_get_parcels_db_to()
provides a table for one territorial office and its municipalities.
Usage
catr_atom_get_parcels_db_all(
cache = deprecated(),
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
catr_atom_get_parcels_db_to(
to,
cache = deprecated(),
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
Arguments
cache |
|
update_cache |
Logical. Should the cached file be refreshed? Defaults to
|
cache_dir |
Path to a cache directory. On |
verbose |
Logical. If |
to |
Character. Territorial office. Internally uses |
Value
A tibble with the information requested with the following fields:
-
territorial_office: Territorial office, corresponding to each province of Spain except the Basque Country and Navarre. -
url: ATOM URL for the corresponding territorial office. -
munic: Name of the municipality. -
date: Reference date of the data. The information from this service is updated twice a year.
Source
https://www.catastro.hacienda.gob.es/INSPIRE/CadastralParcels/ES.SDGC.CP.atom.xml
See Also
Related INSPIRE API functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer(),
inspire_wfs_get()
Related ATOM INSPIRE functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_search_munic()
Other parcels:
catr_atom_get_parcels(),
catr_wfs_get_parcels_bbox()
Other databases:
catr_atom_get_address_db_all(),
catr_atom_get_buildings_db_all(),
catr_atom_search_munic(),
catr_srs_values
Examples
catr_atom_get_parcels_db_all()
ATOM INSPIRE: search for municipality codes
Description
Search for a municipality (as a string, part of a string, or code) and get the corresponding code according to the Cadastre.
Usage
catr_atom_search_munic(
munic,
to = NULL,
cache = deprecated(),
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
Arguments
munic |
Municipality to extract, can be part of a string or a
cadastral code. See |
to |
Optional argument for defining the territorial office to which
|
cache |
|
update_cache |
Logical. Should the cached file be refreshed? Defaults to
|
cache_dir |
Path to a cache directory. On |
verbose |
Logical. If |
Value
A tibble.
See Also
Related ATOM INSPIRE functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all()
Other search:
catr_get_code_from_coords(),
catr_ovc_get_cod_munic(),
catr_ovc_get_cod_provinces()
Other databases:
catr_atom_get_address_db_all(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels_db_all(),
catr_srs_values
Examples
catr_atom_search_munic("Mad")
Clear your CatastRo cache directory
Description
Use this function with caution. This function clears your cached data and configuration, specifically:
Deletes the CatastRo config directory (
tools::R_user_dir("CatastRo", "config")).Deletes the
cache_dirdirectory.Deletes the values stored on
Sys.getenv("CATASTROESP_CACHE_DIR").
Usage
catr_clear_cache(config = FALSE, cached_data = TRUE, verbose = FALSE)
Arguments
config |
If |
cached_data |
If |
verbose |
Logical. If |
Details
This function resets your cache state as if you had never installed and/or used CatastRo.
Value
Invisible. This function is called for its side effects.
See Also
Other cache utilities:
catr_set_cache_dir()
Examples
# Don't run this! It modifies your current state
## Not run:
my_cache <- catr_detect_cache_dir()
# Set an example cache
ex <- file.path(tempdir(), "example", "cache")
catr_set_cache_dir(ex, verbose = FALSE)
# Restore initial cache
catr_clear_cache(verbose = TRUE)
catr_set_cache_dir(my_cache)
identical(my_cache, catr_detect_cache_dir())
## End(Not run)
Get the cadastral municipality code from coordinates
Description
Get the municipality code for coordinates using a sf
object or a pair of coordinates via catr_ovc_get_cod_munic().
Usage
catr_get_code_from_coords(
x,
srs = NULL,
verbose = FALSE,
cache_dir = NULL,
...
)
Arguments
x |
Can be one of:
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
verbose |
Logical. If |
cache_dir |
Path to a cache directory. On |
... |
Arguments passed on to
|
Details
On a successful query, this function returns a tibble with one row including the following columns:
-
munic: Name of the municipality according to the Cadastre. -
catr_to: Cadastral territorial office code. -
catr_munic: Municipality code as recorded on the Cadastre. -
catrcode: Full Cadastral code for the municipality. -
cpro: Province code according to the INE. -
cmun: Municipality code according to the INE. -
inecode: Full INE code for the municipality. Remaining fields: Check the API documentation.
Value
A tibble. See Details.
See Also
mapSpain::esp_get_munic_siane(), catr_ovc_get_cod_munic(),
sf::st_centroid().
Other search:
catr_atom_search_munic(),
catr_ovc_get_cod_munic(),
catr_ovc_get_cod_provinces()
Examples
# Use with coordinates
catr_get_code_from_coords(c(-16.25462, 28.46824), srs = 4326)
# Use with sf
prov <- mapSpain::esp_get_prov("Caceres")
catr_get_code_from_coords(prov)
OVCCallejero: extract the code of a municipality
Description
Implementation of the OVCCallejero service ConsultaMunicipioCodigos. Returns names and codes of a municipality according to the Cadastre and the INE (National Statistics Institute).
Usage
catr_ovc_get_cod_munic(cpro, cmun = NULL, cmun_ine = NULL, verbose = FALSE)
Arguments
cpro |
The code of a province, as provided by
|
cmun, cmun_ine |
Code of a municipality, as recorded on the Spanish
Cadastre ( |
verbose |
Logical. If |
Details
On a successful query, this function returns a tibble with one row including the following columns:
-
munic: Name of the municipality according to the Cadastre. -
catr_to: Cadastral territorial office code. -
catr_munic: Municipality code as recorded on the Cadastre. -
catrcode: Full Cadastral code for the municipality. -
cpro: Province code according to the INE. -
cmun: Municipality code according to the INE. -
inecode: Full INE code for the municipality. Remaining fields: Check the API documentation.
Value
A tibble. See Details.
References
See Also
mapSpain::esp_get_munic_siane() to get shapes of municipalities, including
the INE code.
Related OVCCallejero functions:
catr_ovc_get_cod_provinces()
Other search:
catr_atom_search_munic(),
catr_get_code_from_coords(),
catr_ovc_get_cod_provinces()
Examples
# Get municipality by cadastral code
ab <- catr_ovc_get_cod_munic(cpro = 2, cmun = 900)
ab
# Same query using the INE code
ab2 <- catr_ovc_get_cod_munic(cpro = 2, cmun_ine = 3)
ab2
OVCCallejero: extract provinces with their codes
Description
Implementation of the OVCCallejero service ConsultaProvincia. Returns a list of provinces included in the Spanish Cadastre.
Usage
catr_ovc_get_cod_provinces(verbose = FALSE)
Arguments
verbose |
Logical. If |
Value
A tibble.
References
See Also
Related OVCCallejero functions:
catr_ovc_get_cod_munic()
Other search:
catr_atom_search_munic(),
catr_get_code_from_coords(),
catr_ovc_get_cod_munic()
Examples
catr_ovc_get_cod_provinces()
OVCCoordenadas: geocode a cadastral reference
Description
Implementation of the OVCCoordenadas service Consulta CPMRC. Returns coordinates for a specific cadastral reference.
Usage
catr_ovc_get_cpmrc(
rc,
srs = 4326,
province = NULL,
municipality = NULL,
verbose = FALSE
)
Arguments
rc |
The cadastral reference to be geocoded. |
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
province, municipality |
Optional, used for narrowing the search. |
verbose |
Logical. If |
Details
When the API does not provide any result, this function returns a tibble with the input arguments only.
On a successful query, this function returns a tibble with one row per cadastral reference, including the following columns:
-
xcoord,ycoord: X and Y coordinates in the specified SRS. -
refcat: Cadastral reference. -
address: Address as recorded in the Cadastre. Remaining fields: Check the API documentation.
Value
A tibble. See Details.
References
See Also
catr_srs_values, vignette("ovcservice", package = "CatastRo")
Related OVCCoordenadas functions:
catr_ovc_get_rccoor(),
catr_ovc_get_rccoor_distancia(),
catr_srs_values
Other cadastral references:
catr_ovc_get_rccoor(),
catr_ovc_get_rccoor_distancia()
Examples
# Using all arguments
catr_ovc_get_cpmrc("13077A01800039",
4230,
province = "CIUDAD REAL",
municipality = "SANTA CRUZ DE MUDELA"
)
# Only the cadastral reference
catr_ovc_get_cpmrc("9872023VH5797S")
OVCCoordenadas: reverse geocode a cadastral reference
Description
Implementation of the OVCCoordenadas service Consulta RCCOOR. Returns the cadastral reference found for a set of specific coordinates.
Usage
catr_ovc_get_rccoor(lat, lon, srs = 4326, verbose = FALSE)
Arguments
lat |
Latitude for the query, expressed in the CRS/SRS defined by
|
lon |
Longitude for the query, expressed in the CRS/SRS defined by
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
verbose |
Logical. If |
Details
When the API does not provide any result, the function returns a tibble with the input arguments only.
On a successful query, this function returns a tibble with one row per cadastral reference, including the following columns:
-
geo.xcen,geo.ycen,geo.srs: Input arguments of the query. -
refcat: Cadastral reference. -
address: Address as recorded in the Cadastre. Remaining fields: Check the API documentation.
Value
A tibble. See Details.
References
See Also
catr_srs_values, vignette("ovcservice", package = "CatastRo")
Related OVCCoordenadas functions:
catr_ovc_get_cpmrc(),
catr_ovc_get_rccoor_distancia(),
catr_srs_values
Other cadastral references:
catr_ovc_get_cpmrc(),
catr_ovc_get_rccoor_distancia()
Examples
catr_ovc_get_rccoor(
lat = 38.6196566583596,
lon = -3.45624183836806,
srs = 4326
)
OVCCoordenadas: reverse geocode cadastral references near coordinates
Description
Implementation of the OVCCoordenadas service Consulta RCCOOR Distancia. Returns cadastral references for coordinates. If none found, the API returns references in a 50 square meter area around the requested coordinates.
Usage
catr_ovc_get_rccoor_distancia(lat, lon, srs = 4326, verbose = FALSE)
Arguments
lat |
Latitude for the query, expressed in the CRS/SRS defined by
|
lon |
Longitude for the query, expressed in the CRS/SRS defined by
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
verbose |
Logical. If |
Details
When the API does not provide any result, the function returns a tibble with the input arguments only.
On a successful query, this function returns a tibble with one row per cadastral reference, including the following columns:
-
geo.xcen,geo.ycen,geo.srs: Input arguments of the query. -
refcat: Cadastral reference. -
address: Address as recorded in the Cadastre. -
cmun_ine: Municipality code as registered on the INE (National Statistics Institute). Remaining fields: Check the API documentation.
Value
A tibble. See Details.
References
See Also
catr_srs_values, vignette("ovcservice", package = "CatastRo")
Related OVCCoordenadas functions:
catr_ovc_get_cpmrc(),
catr_ovc_get_rccoor(),
catr_srs_values
Other cadastral references:
catr_ovc_get_cpmrc(),
catr_ovc_get_rccoor()
Examples
catr_ovc_get_rccoor_distancia(
lat = 40.963200,
lon = -5.671420,
srs = 4326
)
Set your CatastRo cache directory
Description
Store your cache_dir path locally for future sessions.
Type Sys.getenv("CATASTROESP_CACHE_DIR") or use
catr_detect_cache_dir() to find your cached path.
Usage
catr_set_cache_dir(
cache_dir = NULL,
overwrite = FALSE,
install = FALSE,
verbose = TRUE
)
catr_detect_cache_dir()
Arguments
cache_dir |
Path to a cache directory. On |
overwrite |
Logical. If |
install |
Logical. If |
verbose |
Logical. If |
Details
By default, when no cache_dir is set, the package uses a folder inside
base::tempdir() (so files are temporary and are removed when the R
session ends). To persist a cache across R sessions, use
catr_set_cache_dir(cache_dir, install = TRUE) which writes the chosen
path to a small configuration file under
tools::R_user_dir("CatastRo", "config").
Value
catr_set_cache_dir() returns an (invisible) character with the path to
your cache_dir, but it is mainly called for its side effect.
catr_detect_cache_dir() returns the path to the cache_dir used in this
session.
Caching strategies
Some files can be read from their online source without caching using the
option cache = FALSE. Otherwise the source file is downloaded to
your computer. CatastRo implements the following caching options:
For occasional use, rely on the default
tempdir()-based cache (no install).Modify the cache for a single session by setting
catr_set_cache_dir(cache_dir = "a/path/here").For reproducible workflows, install a persistent cache with
catr_set_cache_dir(cache_dir = "a/path/here", install = TRUE). This cache is kept across R sessions.For caching specific files, use the
cache_dirargument in the corresponding function.
Sometimes cached files may be corrupt. In that case, try re-downloading
the data by setting update_cache = TRUE in the corresponding function.
If you experience any problem downloading, try downloading the
corresponding file by another method and save it in your
cache_dir. Use the option verbose = TRUE to debug the API query
and catr_detect_cache_dir() to identify your cached path.
Note
In CatastRo >= 1.0.0 the location of the configuration file has
moved from rappdirs::user_config_dir("CatastRo", "R") to
tools::R_user_dir("CatastRo", "config"). We have implemented a
function that migrates previous configuration files from one location to
another with a message. This message appears only once to inform you of the
migration.
See Also
Other cache utilities:
catr_clear_cache()
Examples
# Caution! This modifies your current state
## Not run:
my_cache <- catr_detect_cache_dir()
# Set an example cache
ex <- file.path(tempdir(), "example", "cachenew")
catr_set_cache_dir(ex)
catr_detect_cache_dir()
# Restore initial cache
catr_set_cache_dir(my_cache)
identical(my_cache, catr_detect_cache_dir())
## End(Not run)
catr_detect_cache_dir()
Reference SRS codes for CatastRo services
Description
A tibble including the valid SRS (also known as CRS) values that may be used in each API service. Values are provided as EPSG codes.
Format
A tibble with 16 rows and columns:
- SRS
Spatial Reference System (CRS) value, identified by the corresponding EPSG code.
- Description
Description of the SRS/EPSG code.
- ovc_service
Logical. Whether this code is valid for OVC services.
- wfs_service
Logical. Whether this code is valid for WFS INSPIRE services.
Details
Table: Content of catr_srs_values
| SRS | Description | ovc_service | wfs_service |
3785 | Web Mercator | FALSE | TRUE |
3857 | Web Mercator | FALSE | TRUE |
4230 | Geográficas en ED 50 | TRUE | FALSE |
4258 | Geográficas en ETRS89 | TRUE | TRUE |
4326 | Geográficas en WGS 80 | TRUE | TRUE |
23029 | UTM huso 29N en ED50 | TRUE | FALSE |
23030 | UTM huso 30N en ED50 | TRUE | FALSE |
23031 | UTM huso 31N en ED50 | TRUE | FALSE |
25829 | UTM huso 29N en ETRS89 | TRUE | TRUE |
25830 | UTM huso 30N en ETRS89 | TRUE | TRUE |
25831 | UTM huso 31N en ETRS89 | TRUE | TRUE |
32627 | UTM huso 27N en WGS 84 | TRUE | FALSE |
32628 | UTM huso 28N en WGS 84 | TRUE | FALSE |
32629 | UTM huso 29N en WGS 84 | TRUE | FALSE |
32630 | UTM huso 30N en WGS 84 | TRUE | FALSE |
32631 | UTM huso 31N en WGS 84 | TRUE | FALSE
|
References
See Also
Other databases:
catr_atom_get_address_db_all(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels_db_all(),
catr_atom_search_munic()
Related WFS INSPIRE functions:
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
inspire_wfs_get()
Related OVCCoordenadas functions:
catr_ovc_get_cpmrc(),
catr_ovc_get_rccoor(),
catr_ovc_get_rccoor_distancia()
Examples
data("catr_srs_values")
# OVC valid codes
library(dplyr)
catr_srs_values |> filter(ovc_service)
# WFS valid codes
catr_srs_values |> filter(wfs_service)
# Use with sf::st_crs()
catr_srs_values |>
filter(wfs_service & ovc_service) |>
print() |>
# Select the first value.
slice_head(n = 1) |>
pull(SRS) |>
# Convert to a CRS.
sf::st_crs(.)
WFS INSPIRE: download addresses
Description
Get the spatial data of addresses. The WFS service allows performing several types of queries:
By bounding box:
catr_wfs_get_address_bbox()extracts objects included in the provided bounding box. See Bounding box.
By street code:
catr_wfs_get_address_codvia()extracts objects for specific addresses.
By cadastral reference:
catr_wfs_get_address_rc()extracts objects for specific cadastral references.
By postal codes:
catr_wfs_get_address_postalcode()extracts objects for specific postal codes.
Usage
catr_wfs_get_address_bbox(x, srs = NULL, verbose = FALSE)
catr_wfs_get_address_codvia(codvia, del, mun, srs = NULL, verbose = FALSE)
catr_wfs_get_address_rc(rc, srs = NULL, verbose = FALSE)
catr_wfs_get_address_postalcode(postalcode, srs = NULL, verbose = FALSE)
Arguments
x |
See Bounding box. Can be one of:
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
verbose |
Logical. If |
codvia |
Cadastral street code. |
del |
Cadastral office code. |
mun |
Cadastral municipality code. |
rc |
The cadastral reference to be extracted. |
postalcode |
Postal code. |
Value
A sf object.
API Limits
The API service is limited to a bounding box of 4 km2 and a maximum of 5,000 elements.
Bounding box
When x is a numeric vector, make sure that the srs matches the
coordinate values. Additionally, the function queries the bounding box on
EPSG:25830 - ETRS89 / UTM zone 30N, to overcome
a potential bug on the API side.
When x is a sf object, the value srs is ignored. In
this case, the bounding box of the sf object is
used for the query (see sf::st_bbox()).
The result is always provided in the SRS of the sf object
provided as input.
References
INSPIRE services for cadastral cartography.
See Also
Related INSPIRE API functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer(),
inspire_wfs_get()
Related WFS INSPIRE functions:
catr_srs_values,
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
inspire_wfs_get()
Other addresses:
catr_atom_get_address(),
catr_atom_get_address_db_all()
Other spatial:
catr_atom_get_address(),
catr_atom_get_buildings(),
catr_atom_get_parcels(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer()
Examples
ad <- catr_wfs_get_address_bbox(
c(
233673, 4015968, 233761, 4016008
),
srs = 25830
)
library(ggplot2)
ggplot(ad) +
geom_sf()
WFS INSPIRE: download buildings
Description
Get the spatial data of buildings. The WFS service allows performing two types of queries:
By bounding box:
catr_wfs_get_buildings_bbox()extracts objects included in the provided bounding box. See Bounding box.
By cadastral reference:
catr_wfs_get_buildings_rc()extracts objects for specific cadastral references.
Usage
catr_wfs_get_buildings_bbox(
x,
what = c("building", "buildingpart", "other"),
srs = NULL,
verbose = FALSE
)
catr_wfs_get_buildings_rc(
rc,
what = c("building", "buildingpart", "other"),
srs = NULL,
verbose = FALSE
)
Arguments
x |
See Bounding box. Can be one of:
|
what |
Information to load. Options are:
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
verbose |
Logical. If |
rc |
The cadastral reference to be extracted. |
Value
A sf object.
API Limits
The API service is limited to a bounding box of 4 km2 and a maximum of 5,000 elements.
Bounding box
When x is a numeric vector, make sure that the srs matches the
coordinate values. Additionally, the function queries the bounding box on
EPSG:25830 - ETRS89 / UTM zone 30N, to overcome
a potential bug on the API side.
When x is a sf object, the value srs is ignored. In
this case, the bounding box of the sf object is
used for the query (see sf::st_bbox()).
The result is always provided in the SRS of the sf object
provided as input.
References
INSPIRE services for cadastral cartography.
See Also
Related INSPIRE API functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_wfs_get_address_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer(),
inspire_wfs_get()
Related WFS INSPIRE functions:
catr_srs_values,
catr_wfs_get_address_bbox(),
catr_wfs_get_parcels_bbox(),
inspire_wfs_get()
Other buildings:
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all()
Other spatial:
catr_atom_get_address(),
catr_atom_get_buildings(),
catr_atom_get_parcels(),
catr_wfs_get_address_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer()
Examples
# Using a bbox
building <- catr_wfs_get_buildings_bbox(
c(
376550,
4545424,
376600,
4545474
),
srs = 25830
)
library(ggplot2)
ggplot(building) +
geom_sf() +
labs(title = "Search using bbox")
# Using a cadastral reference
rc <- catr_wfs_get_buildings_rc("6656601UL7465N")
library(ggplot2)
ggplot(rc) +
geom_sf() +
labs(title = "Search using rc")
WFS INSPIRE: download cadastral parcels
Description
Get the spatial data of cadastral parcels and zones. The WFS service allows several types of queries:
By bounding box:
catr_wfs_get_parcels_bbox()extracts objects included in the provided bounding box. See Bounding box.
By zoning:
catr_wfs_get_parcels_zoning()extracts objects for a specific cadastral zone.
By cadastral parcel:
catr_wfs_get_parcels_parcel()extracts cadastral parcels for a specific cadastral reference.
Neighbor cadastral parcels:
catr_wfs_get_parcels_neigh_parcel()extracts neighbor cadastral parcels for a specific cadastral reference.
Cadastral parcels by zoning:
catr_wfs_get_parcels_parcel_zoning()extracts cadastral parcels for a specific cadastral zone.
Usage
catr_wfs_get_parcels_bbox(
x,
what = c("parcel", "zoning"),
srs = NULL,
verbose = FALSE
)
catr_wfs_get_parcels_zoning(cod_zona, srs = NULL, verbose = FALSE)
catr_wfs_get_parcels_parcel(rc, srs = NULL, verbose = FALSE)
catr_wfs_get_parcels_neigh_parcel(rc, srs = NULL, verbose = FALSE)
catr_wfs_get_parcels_parcel_zoning(cod_zona, srs = NULL, verbose = FALSE)
Arguments
x |
See Bounding box. Can be one of:
|
what |
Information to load. Options are:
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
verbose |
Logical. If |
cod_zona |
Cadastral zone code. |
rc |
The cadastral reference to be extracted. |
Value
A sf object.
API Limits
The API service is limited to the following constraints:
-
"parcel": Bounding box of 1 km2 and a maximum of 5,000 elements. -
"zoning": Bounding box of 25 km2 and a maximum of 5,000 elements.
Bounding box
When x is a numeric vector, make sure that the srs matches the
coordinate values. Additionally, the function queries the bounding box on
EPSG:25830 - ETRS89 / UTM zone 30N, to overcome
a potential bug on the API side.
When x is a sf object, the value srs is ignored. In
this case, the bounding box of the sf object is
used for the query (see sf::st_bbox()).
The result is always provided in the SRS of the sf object
provided as input.
References
INSPIRE services for cadastral cartography.
See Also
Related INSPIRE API functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wms_get_layer(),
inspire_wfs_get()
Related WFS INSPIRE functions:
catr_srs_values,
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
inspire_wfs_get()
Other parcels:
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all()
Other spatial:
catr_atom_get_address(),
catr_atom_get_buildings(),
catr_atom_get_parcels(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wms_get_layer()
Examples
cp <- catr_wfs_get_parcels_bbox(
c(
233673, 4015968, 233761, 4016008
),
srs = 25830
)
library(ggplot2)
ggplot(cp) +
geom_sf()
WMS INSPIRE: download map images
Description
Get geotagged images from the Spanish Cadastre. This function is a
wrapper of mapSpain::esp_get_tiles().
Usage
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,
...
)
Arguments
x |
See Bounding box. Can be one of:
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
what, styles |
Layer and style of the WMS layer to be downloaded. See Layers and styles. |
update_cache |
Logical. Should the cached file be refreshed? Defaults to
|
cache_dir |
Path to a cache directory. On |
verbose |
Logical. If |
crop |
logical. If |
options |
A named list containing additional options to pass to the query. |
... |
Arguments passed on to
|
Value
A SpatRaster is returned, with 3 (RGB) or 4 (RGBA) layers,
see terra::RGB().
Bounding box
When x is a numeric vector, make sure that the srs matches the
coordinate values. When x is a sf object, the value
srs is ignored.
The query is performed using EPSG:3857 (Web Mercator)
and the tile is projected back to the SRS of x. In case that the tile
looks deformed, try either providing x or specify the SRS of the requested
tile via the srs argument, which should match the SRS of
x. See Examples.
Layers and styles
Layers
The argument what defines the layer to be extracted. The equivalence with
the
API documentation
reference is:
-
"parcel": CP.CadastralParcel -
"zoning": CP.CadastralZoning -
"building": BU.Building -
"buildingpart": BU.BuildingPart -
"address": AD.Address -
"admboundary": AU.AdministrativeBoundary -
"admunit": AU.AdministrativeUnit
Styles
The WMS service provides different styles for each layer (what argument).
Some available styles are:
-
"parcel": Styles:"BoundariesOnly","ReferencePointOnly","ELFCadastre". -
"zoning": Styles:"BoundariesOnly","ELFCadastre". -
"building","buildingpart":"ELFCadastre". -
"address":"Number.ELFCadastre". -
"admboundary","admunit":"ELFCadastre".
Check the API documentation for more information.
See Also
mapSpain::esp_get_tiles() and terra::RGB(). For plotting see
terra::plotRGB() and tidyterra::geom_spatraster_rgb().
Related INSPIRE API functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
inspire_wfs_get()
Other spatial:
catr_atom_get_address(),
catr_atom_get_buildings(),
catr_atom_get_parcels(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox()
Examples
# With a bbox
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)
Client tool for WFS INSPIRE services
Description
Access WFS INSPIRE services. This function is used internally in WFS calls and is exposed for users and developers accessing other cadastral or INSPIRE resources.
Usage
inspire_wfs_get(
scheme = "https",
hostname = "ovc.catastro.meh.es",
path = "INSPIRE/wfsCP.aspx",
query = list(),
verbose = FALSE
)
Arguments
scheme |
Character string. Protocol to access the resource on the Internet. |
hostname |
Character string. Host that holds the resource. |
path |
Character string. Specific resource in the host to access. |
query |
Named list. Names and values of arguments for the query. |
verbose |
Logical. If |
Details
This function is used internally in all the WFS calls. We expose it to make it available to other users and/or developers for accessing other cadastral or INSPIRE resources. See Examples.
Value
Character string. Path of the resulting file in the tempfile() folder.
See Also
Related INSPIRE API functions:
catr_atom_get_address(),
catr_atom_get_address_db_all(),
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all(),
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all(),
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
catr_wms_get_layer()
Related WFS INSPIRE functions:
catr_srs_values,
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox()
Examples
# Access the Cadastre of Navarra
# Try also https://ropenspain.github.io/CatastRoNav/
file_local <- inspire_wfs_get(
hostname = "inspire.navarra.es",
path = "services/BU/wfs",
query = list(
service = "WFS",
request = "getfeature",
typenames = "BU:Building",
bbox = "609800,4740100,611000,4741300",
SRSNAME = "EPSG:25830"
)
)
if (!is.null(file_local)) {
pamp <- sf::read_sf(file_local)
library(ggplot2)
ggplot(pamp) +
geom_sf()
}
Decide whether an example should run
Description
Determine whether an example should run based on the current platform and network availability.
Usage
run_example()
Details
Returns FALSE on CRAN, macOS, or when offline.
Value
Logical. TRUE if examples should run, FALSE otherwise.
Examples
run_example()