| Title: | Interface to the API 'Sede Electronica Del Catastro' |
| Version: | 1.0.0 |
| Description: | Access public spatial data available under the 'INSPIRE' directive. Tools for downloading references and addresses of properties, as well as map images. |
| 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/testthat/edition: | 3 |
| Config/testthat/parallel: | true |
| Copyright: | © Dirección General del Catastro <https://www.catastro.meh.es/> |
| Encoding: | UTF-8 |
| LazyData: | true |
| RoxygenNote: | 7.3.3 |
| 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-02-23 20:06:52 UTC; diego |
| Author: | Ángel Delgado Panadero
|
| Maintainer: | Diego Hernangómez <diego.hernangomezherrero@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-02-23 20:20:02 UTC |
CatastRo: Interface to the API 'Sede Electronica Del Catastro'
Description
Access public spatial data available under the 'INSPIRE' directive. Tools for downloading references and addresses of properties, as well as map images.
Author(s)
Maintainer: Diego Hernangómez diego.hernangomezherrero@gmail.com (ORCID)
Authors:
Á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 INSPIRE ATOM service. The 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. It can be a part of a string or the
cadastral code. See |
to |
Optional argument for defining the territorial office to which
|
cache |
|
update_cache |
logical. Should the cached file be refreshed? Default is
|
cache_dir |
A path to a cache directory. On |
verbose |
logical. If |
Value
A sf object.
References
INSPIRE Services for Cadastral Cartography.
See Also
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()
Other INSPIRE ATOM services:
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 INSPIRE ATOM service of the Spanish Cadastre for extracting addresses.
-
catr_atom_get_address_db_all()provides a top-level table including information on all the territorial offices (except the Basque Country and Navarre) listing the municipalities included in each office. -
catr_atom_get_address_db_to()provides a table for the specified territorial office including information for each of the municipalities of that office.
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? Default is
|
cache_dir |
A 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. Note that 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
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()
Other INSPIRE ATOM services:
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 INSPIRE ATOM 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. It can be a part of a string or the
cadastral code. See |
to |
Optional argument for defining the territorial office to which
|
what |
Information to load. It can be:
|
cache |
|
update_cache |
logical. Should the cached file be refreshed? Default is
|
cache_dir |
A path to a cache directory. On |
verbose |
logical. If |
Value
A sf object.
References
INSPIRE Services for Cadastral Cartography.
See Also
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()
Other INSPIRE ATOM services:
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 INSPIRE ATOM service of the Spanish Cadastre for extracting buildings.
-
catr_atom_get_buildings_db_all()provides a top-level table including information on all the territorial offices (except the Basque Country and Navarre) listing the municipalities included in each office. -
catr_atom_get_buildings_db_to()provides a table for the specified territorial office including information for each of the municipalities of that office.
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? Default is
|
cache_dir |
A 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. Note that 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
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()
Other INSPIRE ATOM services:
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 INSPIRE ATOM 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. It can be a part of a string or the
cadastral code. See |
to |
Optional argument for defining the territorial office to which
|
what |
Information to load. It can be:
|
cache |
|
update_cache |
logical. Should the cached file be refreshed? Default is
|
cache_dir |
A path to a cache directory. On |
verbose |
logical. If |
Value
A sf object.
References
INSPIRE Services for Cadastral Cartography.
See Also
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()
Other INSPIRE ATOM services:
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 INSPIRE ATOM service of the Spanish Cadastre for extracting cadastral parcels.
-
catr_atom_get_parcels_db_all()provides a top-level table including information on all the territorial offices (except the Basque Country and Navarre) listing the municipalities included in each office. -
catr_atom_get_parcels_db_to()provides a table for the specified territorial office including information for each of the municipalities of that office.
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? Default is
|
cache_dir |
A 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. Note that 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
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()
Other INSPIRE ATOM services:
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 as per 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. It can be a part of a string or the
cadastral code. See |
to |
Optional argument for defining the territorial office to which
|
cache |
|
update_cache |
logical. Should the cached file be refreshed? Default is
|
cache_dir |
A path to a cache directory. On |
verbose |
logical. If |
Value
A tibble.
See Also
Other INSPIRE ATOM services:
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 dir
Description
Use this function with caution. This function will clear 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 this is set to |
verbose |
logical. If |
Details
This is an overkill function that is intended to reset your status as if you would never have 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 would modify 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
This function takes as input a pair of coordinates of a sf
object and returns the corresponding municipality code for those coordinates
using catr_ovc_get_cod_munic().
Usage
catr_get_code_from_coords(
x,
srs = NULL,
verbose = FALSE,
cache_dir = NULL,
...
)
Arguments
x |
It can be:
|
srs |
SRS/CRS to use on the query. To check the admitted values check
catr_srs_values, specifically the |
verbose |
logical. If |
cache_dir |
A path to a cache directory. On |
... |
Arguments passed on to
|
Details
On a successful query, the function returns a tibble with one row including the following columns:
-
munic: Name of the municipality as per 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 as per the INE. -
catr_munic: Municipality code as per the INE. -
catrcode: Full INE code for the municipality. Rest of fields: Check the API Docs.
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 coords
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 the names and codes of a municipality. Returns both the codes as per the Cadastre and as per 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, the function returns a tibble with one row including the following columns:
-
munic: Name of the municipality as per 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 as per the INE. -
catr_munic: Municipality code as per the INE. -
catrcode: Full INE code for the municipality. Rest of fields: Check the API Docs.
Value
A tibble. See Details
References
See Also
mapSpain::esp_get_munic_siane() to get shapes of municipalities, including
the INE code.
OVCCoordenadas API:
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 cadastal 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 a list of provinces with their codes
Description
Implementation of the OVCCallejero service ConsultaProvincia.
Returns a list of the provinces included in the Spanish Cadastre.
Usage
catr_ovc_get_cod_provinces(verbose = FALSE)
Arguments
verbose |
logical. If |
Value
A tibble.
References
See Also
OVCCoordenadas API:
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 the 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 on the query. To check the admitted values check
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, the function returns a tibble with the input arguments only.
On a successful query, the 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 it is recorded on the Cadastre. Rest of fields: Check the API Docs.
Value
A tibble. See Details
References
See Also
catr_srs_values, vignette("ovcservice", package = "CatastRo")
OVCCoordenadas API:
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 the 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 to use on the query. It should be specified in the
CRS/SRS defined in |
lon |
Longitude to use on the query. It should be specified in the
CRS/SRS defined in |
srs |
SRS/CRS to use on the query. To check the admitted values check
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, the function returns a tibble with one row by cadastral reference, including the following columns:
-
geo.xcen,geo.ycen,geo.srs: Input arguments of the query. -
refcat: Cadastral Reference. -
address: Address as it is recorded on the Cadastre. Rest of fields: Check the API Docs.
Value
A tibble. See Details
References
See Also
catr_srs_values, vignette("ovcservice", package = "CatastRo")
OVCCoordenadas API:
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 on a region
Description
Implementation of the OVCCoordenadas service Consulta RCCOOR Distancia.
Returns the cadastral reference found for a set of coordinates. If no cadastral references are found, the API returns a list of the cadastral references found in an area of 50 square meters around the requested coordinates.
Usage
catr_ovc_get_rccoor_distancia(lat, lon, srs = 4326, verbose = FALSE)
Arguments
lat |
Latitude to use on the query. It should be specified in the
CRS/SRS defined in |
lon |
Longitude to use on the query. It should be specified in the
CRS/SRS defined in |
srs |
SRS/CRS to use on the query. To check the admitted values check
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, the function returns a tibble with one row by cadastral reference, including the following columns:
-
geo.xcen,geo.ycen,geo.srs: Input arguments of the query. -
refcat: Cadastral reference. -
address: Address as it is recorded on the Cadastre. -
cmun_ine: Municipality code as registered on the INE (National Statistics Institute). Rest of fields: Check the API Docs.
Value
A tibble. See Details
References
See Also
catr_srs_values, vignette("ovcservice", package = "CatastRo")
OVCCoordenadas API:
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 dir
Description
This function will store your cache_dir path on your local machine and
will load it for future sessions. Type Sys.getenv("CATASTROESP_CACHE_DIR")
to find your cached path or use catr_detect_cache_dir().
Usage
catr_set_cache_dir(
cache_dir = NULL,
overwrite = FALSE,
install = FALSE,
verbose = TRUE
)
catr_detect_cache_dir()
Arguments
cache_dir |
A path to a cache directory. On |
overwrite |
If this is set to |
install |
If |
verbose |
logical. If |
Details
By default, when no cache 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 would be 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 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)that would be 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 setting update_cache = TRUE in the corresponding function.
If you experience any problem with downloading, try to download the
corresponding file by any other method and save it on your
cache_dir. Use the option verbose = TRUE for debugging 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
functionality that will migrate previous configuration files from one
location to another with a message. This message will appear only once
informing of the migration.
See Also
Other cache utilities:
catr_clear_cache()
Examples
# Caution! It would modify 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 APIs
Description
A tibble including the valid SRS (also known as CRS) values that may be used on each API service. The 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. Is this code valid on OVC services?
- wfs_service
Logical. Is this code valid on INSPIRE WFS 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()
Other INSPIRE WFS services:
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
inspire_wfs_get()
OVCCoordenadas API:
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 == TRUE)
# WFS valid codes
catr_srs_values |> filter(wfs_service == TRUE)
# Use with sf::st_crs()
catr_srs_values |>
filter(wfs_service == TRUE & ovc_service == TRUE) |>
print() |>
# First value
slice_head(n = 1) |>
pull(SRS) |>
# As 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: Implemented on
catr_wfs_get_address_bbox(). Extract objects included in the bounding box provided. See Bounding box.
By street code: Implemented on
catr_wfs_get_address_codvia(). Extract objects of specific addresses.
By cadastral reference: Implemented on
catr_wfs_get_address_rc(). Extract objects of specific cadastral references.
By postal codes: Implemented on
catr_wfs_get_address_postalcode(). Extract objects of 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. It could be:
|
srs |
SRS/CRS to use on the query. To check the admitted values check
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 4km2 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 would be
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
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()
Other INSPIRE WFS services:
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: Implemented on
catr_wfs_get_buildings_bbox(). Extract objects included in the bounding box provided. See Bounding box.
By cadastral reference: Implemented on
catr_wfs_get_buildings_rc(). Extract objects of 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. It could be:
|
what |
Information to load. It can be:
|
srs |
SRS/CRS to use on the query. To check the admitted values check
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 4km2 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 would be
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
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()
Other INSPIRE WFS services:
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 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 rc
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 to perform several types of queries:
By bounding box: Implemented on
catr_wfs_get_parcels_bbox(). Extract objects included in the bounding box provided. See Bounding box.
By zoning: Implemented on
catr_wfs_get_parcels_zoning(). Extract objects of a specific cadastral zone.
By cadastral parcel: Implemented on
catr_wfs_get_parcels_parcel(). Extract cadastral parcels of a specific cadastral reference.
Neighbor cadastral parcels: Implemented on
catr_wfs_get_parcels_neigh_parcel(). Extract neighbor cadastral parcels of a specific cadastral reference.
Cadastral parcels by zoning: Implemented on
catr_wfs_get_parcels_parcel_zoning(). Extract cadastral parcels of 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. It could be:
|
what |
Information to load. It can be:
|
srs |
SRS/CRS to use on the query. To check the admitted values check
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 1km2 and a maximum of 5,000 elements. -
"zoning": Bounding box of 25km2 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 would be
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
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()
Other INSPIRE WFS services:
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. It could be:
|
srs |
SRS/CRS to use on the query. To check the admitted values check
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? Default is
|
cache_dir |
A 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, that (ideally) would need to 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 Docs
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 on each layer (what argument).
Some of the styles available are:
-
"parcel": styles :"BoundariesOnly","ReferencePointOnly","ELFCadastre". -
"zoning": styles :"BoundariesOnly","ELFCadastre". -
"building","buildingpart":"ELFCadastre" -
"address":"Number.ELFCadastre" -
"admboundary","admunit":"ELFCadastre"
Check the API Docs for more information.
See Also
mapSpain::esp_get_tiles() and terra::RGB(). For plotting see
terra::plotRGB() and tidyterra::geom_spatraster_rgb().
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, # As 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
Client tool for WFS INSPIRE services
Usage
inspire_wfs_get(
scheme = "https",
hostname = "ovc.catastro.meh.es",
path = "INSPIRE/wfsCP.aspx",
query = list(),
verbose = FALSE
)
Arguments
scheme |
Identifies the protocol to be used to access the resource on the Internet. |
hostname |
Identifies the host that holds the resource. |
path |
Identifies the specific resource in the host that the web client wants to access. |
query |
A named list with the name and value of the arguments to 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
A character string with the path of the resulting file in the tempfile()
folder.
See Also
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()
Other INSPIRE WFS services:
catr_srs_values,
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox()
Examples
# Accessing 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()
}
Should the example run?
Description
Internal function to decide whether the example should run or not
Usage
run_example()
Details
On CRAN or on macOS, results in FALSE
Value
logical TRUE or FALSE
Examples
run_example()