| Title: | Interface to the Spanish 'Catastro' Web Services |
|---|---|
| Description: | Access public spatial data from the Spanish Cadastre through its 'INSPIRE' and related web services. Retrieve cadastral parcel, building, address and georeferenced map image data and convert between cadastral references and coordinates. |
| Authors: | Ángel Delgado Panadero [aut, cph] (ORCID: <https://orcid.org/0000-0002-8189-9251>), Iñaki Ucar [ctb] (ORCID: <https://orcid.org/0000-0001-6403-5550>), Diego Hernangómez [aut, cre] (ORCID: <https://orcid.org/0000-0001-8457-4658>) |
| Maintainer: | Diego Hernangómez <[email protected]> |
| License: | GPL-2 |
| Version: | 1.0.2.9000 |
| Built: | 2026-07-13 11:48:39 UTC |
| Source: | https://github.com/rOpenSpain/CatastRo |
Retrieve spatial data for all addresses in a municipality using the ATOM
INSPIRE service. The result also contains corresponding
street information in fields prefixed with tfname_*.
catr_atom_get_address( munic, to = NULL, cache = deprecated(), update_cache = FALSE, cache_dir = NULL, verbose = FALSE )catr_atom_get_address( munic, to = NULL, cache = deprecated(), update_cache = FALSE, cache_dir = NULL, verbose = FALSE )
munic |
Municipality name, partial name or cadastral code. Use
|
to |
Optional territorial office containing |
cache |
|
update_cache |
Logical. Whether to refresh the cached file. Defaults to
|
cache_dir |
Path to a cache directory. If |
verbose |
Logical. If |
An sf object. Returns NULL if the data cannot be
retrieved.
INSPIRE services for cadastral cartography.
Download data from ATOM INSPIRE 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()
Work with cadastral addresses:
catr_atom_get_address_db_all(),
catr_wfs_get_address_bbox()
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" )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" )
Create a table of URLs provided by the Spanish Cadastre ATOM INSPIRE service for downloading addresses.
catr_atom_get_address_db_all() provides a summary 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.
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 )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 )
cache |
|
update_cache |
Logical. Whether to refresh the cached file. Defaults to
|
cache_dir |
Path to a cache directory. If |
verbose |
Logical. If |
to |
Character string. Territorial office to match using |
A tibble with the requested information in the following columns:
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.
https://www.catastro.hacienda.gob.es/INSPIRE/Addresses/ES.SDGC.AD.atom.xml
Download data from ATOM INSPIRE 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()
Work with cadastral addresses:
catr_atom_get_address(),
catr_wfs_get_address_bbox()
catr_atom_get_address_db_all()catr_atom_get_address_db_all()
Retrieve spatial data for all buildings in a municipality using the ATOM INSPIRE service.
catr_atom_get_buildings( munic, to = NULL, what = c("building", "buildingpart", "other"), cache = deprecated(), update_cache = FALSE, cache_dir = NULL, verbose = FALSE )catr_atom_get_buildings( munic, to = NULL, what = c("building", "buildingpart", "other"), cache = deprecated(), update_cache = FALSE, cache_dir = NULL, verbose = FALSE )
munic |
Municipality name, partial name or cadastral code. Use
|
to |
Optional territorial office containing |
what |
Information to load. Options are:
|
cache |
|
update_cache |
Logical. Whether to refresh the cached file. Defaults to
|
cache_dir |
Path to a cache directory. If |
verbose |
Logical. If |
An sf object. Returns NULL if the data cannot be
retrieved.
INSPIRE services for cadastral cartography.
Download data from ATOM INSPIRE 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()
Work with cadastral buildings:
catr_atom_get_buildings_db_all(),
catr_wfs_get_buildings_bbox()
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" )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" )
Create a table of URLs provided by the Spanish Cadastre ATOM INSPIRE service for downloading buildings.
catr_atom_get_buildings_db_all() provides a summary 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.
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 )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 )
cache |
|
update_cache |
Logical. Whether to refresh the cached file. Defaults to
|
cache_dir |
Path to a cache directory. If |
verbose |
Logical. If |
to |
Character string. Territorial office to match using |
A tibble with the requested information in the following columns:
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.
https://www.catastro.hacienda.gob.es/INSPIRE/buildings/ES.SDGC.BU.atom.xml
Download data from ATOM INSPIRE 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()
Work with cadastral buildings:
catr_atom_get_buildings(),
catr_wfs_get_buildings_bbox()
catr_atom_get_buildings_db_all()catr_atom_get_buildings_db_all()
Retrieve spatial data for all cadastral parcels in a municipality using the ATOM INSPIRE service.
catr_atom_get_parcels( munic, to = NULL, what = c("parcel", "zoning"), cache = deprecated(), update_cache = FALSE, cache_dir = NULL, verbose = FALSE )catr_atom_get_parcels( munic, to = NULL, what = c("parcel", "zoning"), cache = deprecated(), update_cache = FALSE, cache_dir = NULL, verbose = FALSE )
munic |
Municipality name, partial name or cadastral code. Use
|
to |
Optional territorial office containing |
what |
Information to load. Options are:
|
cache |
|
update_cache |
Logical. Whether to refresh the cached file. Defaults to
|
cache_dir |
Path to a cache directory. If |
verbose |
Logical. If |
An sf object. Returns NULL if the data cannot be
retrieved.
INSPIRE services for cadastral cartography.
Download data from ATOM INSPIRE 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()
Work with cadastral parcels:
catr_atom_get_parcels_db_all(),
catr_wfs_get_parcels_bbox()
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" )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" )
Create a table of URLs provided by the Spanish Cadastre ATOM INSPIRE service for downloading cadastral parcels.
catr_atom_get_parcels_db_all() provides a summary 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.
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 )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 )
cache |
|
update_cache |
Logical. Whether to refresh the cached file. Defaults to
|
cache_dir |
Path to a cache directory. If |
verbose |
Logical. If |
to |
Character string. Territorial office to match using |
A tibble with the requested information in the following columns:
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.
https://www.catastro.hacienda.gob.es/INSPIRE/CadastralParcels/ES.SDGC.CP.atom.xml
Download data from ATOM INSPIRE 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()
Work with cadastral parcels:
catr_atom_get_parcels(),
catr_wfs_get_parcels_bbox()
catr_atom_get_parcels_db_all()catr_atom_get_parcels_db_all()
Search for a municipality by name or code and return matching Spanish Cadastre municipality codes.
catr_atom_search_munic( munic, to = NULL, cache = deprecated(), update_cache = FALSE, cache_dir = NULL, verbose = FALSE )catr_atom_search_munic( munic, to = NULL, cache = deprecated(), update_cache = FALSE, cache_dir = NULL, verbose = FALSE )
munic |
Municipality name, partial name or cadastral code. Use
|
to |
Optional territorial office containing |
cache |
|
update_cache |
Logical. Whether to refresh the cached file. Defaults to
|
cache_dir |
Path to a cache directory. If |
verbose |
Logical. If |
A tibble with the territorial office,
municipality name and cadastral code. Returns NULL if no match is found.
Download data from ATOM INSPIRE 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()
Search for cadastral identifiers:
catr_get_code_from_coords(),
catr_ovc_get_cod_munic(),
catr_ovc_get_cod_provinces()
catr_atom_search_munic("Mad")catr_atom_search_munic("Mad")
Use this function with caution. Depending on its arguments, this function:
Deletes the CatastRo configuration directory when
config = TRUE
(tools::R_user_dir("CatastRo", "config")).
Deletes the cache_dir directory and its contents when
cached_data = TRUE.
Always clears the CATASTROESP_CACHE_DIR environment variable.
catr_clear_cache(config = FALSE, cached_data = TRUE, verbose = FALSE)catr_clear_cache(config = FALSE, cached_data = TRUE, verbose = FALSE)
config |
If |
cached_data |
If |
verbose |
Logical. If |
With config = TRUE and cached_data = TRUE, this function resets the
cache state as if you had never used CatastRo.
Invisibly returns NULL. This function is called for its side
effects.
tools::R_user_dir() defines platform-specific user directories.
Manage the local cache:
catr_set_cache_dir()
# 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)# 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)
Retrieve the municipality code associated with an sf object
or a coordinate pair.
catr_get_code_from_coords( x, srs = NULL, verbose = FALSE, cache_dir = NULL, ... )catr_get_code_from_coords( x, srs = NULL, verbose = FALSE, cache_dir = NULL, ... )
x |
Coordinate input. It can be:
|
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. If |
... |
Arguments passed on to
|
On a successful query, this function returns a tibble with one row including the following columns:
munic: Municipality name used by the Spanish Cadastre.
catr_to: Cadastral territorial office code.
catr_munic: Municipality code as recorded by 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: See the API documentation.
A tibble as described in Details. Returns
NULL if the request fails.
mapSpain::esp_get_munic_siane() retrieves municipality geometries.
catr_ovc_get_cod_munic() retrieves municipality codes.
sf::st_centroid() computes geometry centroids.
Search for cadastral identifiers:
catr_atom_search_munic(),
catr_ovc_get_cod_munic(),
catr_ovc_get_cod_provinces()
# Use with coordinates catr_get_code_from_coords(c(-16.25462, 28.46824), srs = 4326) # Use with an sf object prov <- mapSpain::esp_get_prov("Caceres") catr_get_code_from_coords(prov)# Use with coordinates catr_get_code_from_coords(c(-16.25462, 28.46824), srs = 4326) # Use with an sf object prov <- mapSpain::esp_get_prov("Caceres") catr_get_code_from_coords(prov)
Query the OVCCallejero ConsultaMunicipioCodigos service to retrieve municipality names and codes from the Spanish Cadastre and the National Statistics Institute (INE).
catr_ovc_get_cod_munic(cpro, cmun = NULL, cmun_ine = NULL, verbose = FALSE)catr_ovc_get_cod_munic(cpro, cmun = NULL, cmun_ine = NULL, verbose = FALSE)
cpro |
Province code returned by
|
cmun, cmun_ine
|
Municipality code as recorded by the Spanish
Cadastre ( |
verbose |
Logical. If |
On a successful query, this function returns a tibble with one row including the following columns:
munic: Municipality name used by the Spanish Cadastre.
catr_to: Cadastral territorial office code.
catr_munic: Municipality code as recorded by 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: See the API documentation.
A tibble as described in Details. Returns
NULL if the request fails.
mapSpain::esp_get_munic_siane() to get shapes of municipalities, including
the INE code.
Query OVC province and municipality codes:
catr_ovc_get_cod_provinces()
Search for cadastral identifiers:
catr_atom_search_munic(),
catr_get_code_from_coords(),
catr_ovc_get_cod_provinces()
# 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# 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
Query the OVCCallejero ConsultaProvincia service to retrieve provinces and their Spanish Cadastre codes.
catr_ovc_get_cod_provinces(verbose = FALSE)catr_ovc_get_cod_provinces(verbose = FALSE)
verbose |
Logical. If |
A tibble with province names and codes. Returns
NULL if the request fails.
Query OVC province and municipality codes:
catr_ovc_get_cod_munic()
Search for cadastral identifiers:
catr_atom_search_munic(),
catr_get_code_from_coords(),
catr_ovc_get_cod_munic()
catr_ovc_get_cod_provinces()catr_ovc_get_cod_provinces()
Query the OVCCoordenadas Consulta CPMRC service to retrieve coordinates for a cadastral reference.
catr_ovc_get_cpmrc( rc, srs = 4326, province = NULL, municipality = NULL, verbose = FALSE )catr_ovc_get_cpmrc( rc, srs = 4326, province = NULL, municipality = NULL, verbose = FALSE )
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 character strings used to narrow the search. |
verbose |
Logical. If |
If the API returns no results, this function returns a tibble containing only query information.
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 Spanish Cadastre.
Remaining fields: See the API documentation.
A tibble as described in Details. Returns
NULL if the request fails.
catr_srs_values lists supported SRS values.
vignette("ovcservice", package = "CatastRo") describes the OVC services.
Convert coordinates and cadastral references:
catr_ovc_get_rccoor(),
catr_ovc_get_rccoor_distancia()
Work with cadastral references:
catr_ovc_get_rccoor(),
catr_ovc_get_rccoor_distancia()
# 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")# 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")
Query the OVCCoordenadas Consulta RCCOOR service to retrieve the cadastral reference associated with a pair of coordinates.
catr_ovc_get_rccoor(lat, lon, srs = 4326, verbose = FALSE)catr_ovc_get_rccoor(lat, lon, srs = 4326, verbose = FALSE)
lat |
Latitude for the query, expressed in the SRS/CRS defined by
|
lon |
Longitude for the query, expressed in the SRS/CRS defined by
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
verbose |
Logical. If |
If the API returns no results, this function returns a tibble containing only query information.
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 Spanish Cadastre.
Remaining fields: See the API documentation.
A tibble as described in Details. Returns
NULL if the request fails.
Convert coordinates and cadastral references:
catr_ovc_get_cpmrc(),
catr_ovc_get_rccoor_distancia()
Work with cadastral references:
catr_ovc_get_cpmrc(),
catr_ovc_get_rccoor_distancia()
catr_ovc_get_rccoor( lat = 38.6196566583596, lon = -3.45624183836806, srs = 4326 )catr_ovc_get_rccoor( lat = 38.6196566583596, lon = -3.45624183836806, srs = 4326 )
Query the OVCCoordenadas Consulta RCCOOR Distancia service to retrieve cadastral references near a pair of coordinates. If no exact match is found, the API searches within 50 square meters of the requested coordinates.
catr_ovc_get_rccoor_distancia(lat, lon, srs = 4326, verbose = FALSE)catr_ovc_get_rccoor_distancia(lat, lon, srs = 4326, verbose = FALSE)
lat |
Latitude for the query, expressed in the SRS/CRS defined by
|
lon |
Longitude for the query, expressed in the SRS/CRS defined by
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
verbose |
Logical. If |
If the API returns no results, this function returns a tibble containing only query information.
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 Spanish Cadastre.
cmun_ine: Municipality code as registered on the INE (National
Statistics Institute).
Remaining fields: See the API documentation.
A tibble as described in Details. Returns
NULL if the request fails.
Convert coordinates and cadastral references:
catr_ovc_get_cpmrc(),
catr_ovc_get_rccoor()
Work with cadastral references:
catr_ovc_get_cpmrc(),
catr_ovc_get_rccoor()
catr_ovc_get_rccoor_distancia( lat = 40.963200, lon = -5.671420, srs = 4326 )catr_ovc_get_rccoor_distancia( lat = 40.963200, lon = -5.671420, srs = 4326 )
Configure the cache directory used by CatastRo. Use
Sys.getenv("CATASTROESP_CACHE_DIR") or catr_detect_cache_dir() to inspect
the current path.
catr_set_cache_dir( cache_dir = NULL, overwrite = FALSE, install = FALSE, verbose = TRUE ) catr_detect_cache_dir()catr_set_cache_dir( cache_dir = NULL, overwrite = FALSE, install = FALSE, verbose = TRUE ) catr_detect_cache_dir()
cache_dir |
Path to a cache directory. If |
overwrite |
Logical. If |
install |
Logical. If |
verbose |
Logical. If |
By default, when no cache_dir is set, CatastRo uses a directory
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").
catr_set_cache_dir() invisibly returns a character string containing the
cache path. It is primarily called for its side effect.
catr_detect_cache_dir() returns the path to the cache_dir used in this
session.
Source files are cached after download. 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_dir argument in the
corresponding function.
Cached files can occasionally become corrupt. In that case, try downloading
the data by setting update_cache = TRUE in the corresponding function.
If a download fails, try another download method and save the file in
cache_dir. Use verbose = TRUE to inspect the API query
and catr_detect_cache_dir() to identify your cache path.
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.
tools::R_user_dir() defines platform-specific user directories.
Manage the local cache:
catr_clear_cache()
# 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()# 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()
A tibble containing valid SRS values, also known as CRS values, for each API service. Values are represented as EPSG codes.
A tibble with 16 rows and columns:
Spatial reference system (SRS) value, also known as a coordinate reference system (CRS), identified by the corresponding EPSG code.
Description of the SRS/EPSG code.
Logical. Whether this code is valid for OVC services.
Logical. Whether this code is valid for WFS INSPIRE services.
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
|
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(.)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(.)
Retrieve spatial address data through several types of WFS queries:
By bounding box: catr_wfs_get_address_bbox() retrieves objects included
in the provided bounding box. See Bounding box.
By street code: catr_wfs_get_address_codvia() retrieves objects for
specific addresses.
By cadastral reference: catr_wfs_get_address_rc() retrieves objects for
specific cadastral references.
By postal codes: catr_wfs_get_address_postalcode() retrieves objects for
specific postal codes.
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)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)
x |
Input defining the query area. See Bounding box. It can be:
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
verbose |
Logical. If |
codvia |
Cadastral street code. |
del |
Cadastral office code. |
mun |
Cadastral municipality code. |
rc |
Cadastral reference to retrieve. |
postalcode |
Postal code. |
An sf object. Returns NULL if the data cannot be
retrieved.
The API service is limited to a bounding box of 4 km2 and a maximum of 5,000 elements.
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 work around a
potential API issue.
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.
INSPIRE services for cadastral cartography.
Query data from WFS INSPIRE services:
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox(),
inspire_wfs_get()
Work with cadastral addresses:
catr_atom_get_address(),
catr_atom_get_address_db_all()
ad <- catr_wfs_get_address_bbox( c( 233673, 4015968, 233761, 4016008 ), srs = 25830 ) library(ggplot2) ggplot(ad) + geom_sf()ad <- catr_wfs_get_address_bbox( c( 233673, 4015968, 233761, 4016008 ), srs = 25830 ) library(ggplot2) ggplot(ad) + geom_sf()
Retrieve spatial building data through two types of WFS queries:
By bounding box: catr_wfs_get_buildings_bbox() retrieves objects included
in the provided bounding box. See Bounding box.
By cadastral reference: catr_wfs_get_buildings_rc() retrieves objects for
specific cadastral references.
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 )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 )
x |
Input defining the query area. See Bounding box. It can be:
|
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 |
Cadastral reference to retrieve. |
An sf object. Returns NULL if the data cannot be
retrieved.
The API service is limited to a bounding box of 4 km2 and a maximum of 5,000 elements.
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 work around a
potential API issue.
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.
INSPIRE services for cadastral cartography.
Query data from WFS INSPIRE services:
catr_wfs_get_address_bbox(),
catr_wfs_get_parcels_bbox(),
inspire_wfs_get()
Work with cadastral buildings:
catr_atom_get_buildings(),
catr_atom_get_buildings_db_all()
# Using a bounding box building <- catr_wfs_get_buildings_bbox( c( 376550, 4545424, 376600, 4545474 ), srs = 25830 ) library(ggplot2) ggplot(building) + geom_sf() + labs(title = "Search using a bounding box") # Using a cadastral reference rc <- catr_wfs_get_buildings_rc("6656601UL7465N") library(ggplot2) ggplot(rc) + geom_sf() + labs(title = "Search using rc")# Using a bounding box building <- catr_wfs_get_buildings_bbox( c( 376550, 4545424, 376600, 4545474 ), srs = 25830 ) library(ggplot2) ggplot(building) + geom_sf() + labs(title = "Search using a bounding box") # Using a cadastral reference rc <- catr_wfs_get_buildings_rc("6656601UL7465N") library(ggplot2) ggplot(rc) + geom_sf() + labs(title = "Search using rc")
Retrieve spatial cadastral parcel and zoning data through several types of WFS queries:
By bounding box: catr_wfs_get_parcels_bbox() retrieves objects included
in the provided bounding box. See Bounding box.
By zoning: catr_wfs_get_parcels_zoning() retrieves objects for a specific
cadastral zone.
By cadastral parcel: catr_wfs_get_parcels_parcel() retrieves cadastral
parcels for a specific cadastral reference.
Neighbor cadastral parcels: catr_wfs_get_parcels_neigh_parcel()
retrieves neighboring cadastral parcels for a specific cadastral reference.
Cadastral parcels by zoning: catr_wfs_get_parcels_parcel_zoning()
retrieves cadastral parcels for a specific cadastral zone.
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)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)
x |
Input defining the query area. See Bounding box. It can be:
|
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 |
Cadastral reference to retrieve. |
An sf object. Returns NULL if the data cannot be
retrieved.
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.
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 work around a
potential API issue.
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.
INSPIRE services for cadastral cartography.
Query data from WFS INSPIRE services:
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
inspire_wfs_get()
Work with cadastral parcels:
catr_atom_get_parcels(),
catr_atom_get_parcels_db_all()
cp <- catr_wfs_get_parcels_bbox( c( 233673, 4015968, 233761, 4016008 ), srs = 25830 ) library(ggplot2) ggplot(cp) + geom_sf()cp <- catr_wfs_get_parcels_bbox( c( 233673, 4015968, 233761, 4016008 ), srs = 25830 ) library(ggplot2) ggplot(cp) + geom_sf()
Retrieve georeferenced map images from the Spanish Cadastre WMS service.
This function wraps mapSpain::esp_get_tiles().
catr_wms_get_layer( x, srs = NULL, what = c("building", "buildingpart", "parcel", "zoning", "address", "admboundary", "admunit"), styles = "default", update_cache = FALSE, cache_dir = NULL, verbose = FALSE, crop = FALSE, options = NULL, ... )catr_wms_get_layer( x, srs = NULL, what = c("building", "buildingpart", "parcel", "zoning", "address", "admboundary", "admunit"), styles = "default", update_cache = FALSE, cache_dir = NULL, verbose = FALSE, crop = FALSE, options = NULL, ... )
x |
Input defining the query area. See Bounding box. It can be:
|
srs |
SRS/CRS to use in the query. To see allowed values, use
catr_srs_values, specifically the |
what |
WMS layer to download. See Layers and styles. |
styles |
Style to apply to the selected WMS layer. See Layers and styles. |
update_cache |
Logical. Whether to refresh the cached file. Defaults to
|
cache_dir |
Path to a cache directory. If |
verbose |
Logical. If |
crop |
Logical. If |
options |
A named list containing additional options to pass to the query. |
... |
Arguments passed on to
|
A SpatRaster with three RGB or four RGBA layers. See
terra::RGB().
When x is a numeric vector, make sure that the srs matches the
coordinate values. When x is a sf object, the value
srs is ignored.
The query uses EPSG:3857 (Web Mercator), then
transforms the tile back to the SRS of x. If the tile appears distorted,
provide a spatial object as x or set srs to the SRS of the requested
tile. See Examples.
The what argument selects one of the following API layers:
"parcel": CP.CadastralParcel.
"zoning": CP.CadastralZoning.
"building": BU.Building.
"buildingpart": BU.BuildingPart.
"address": AD.Address.
"admboundary": AU.AdministrativeBoundary.
"admunit": AU.AdministrativeUnit.
The WMS service provides different styles for each layer (what argument).
Available styles include:
"parcel": "BoundariesOnly", "ReferencePointOnly" and
"ELFCadastre".
"zoning": "BoundariesOnly" and "ELFCadastre".
"building" and "buildingpart": "ELFCadastre".
"address": "Number.ELFCadastre".
"admboundary" and "admunit": "ELFCadastre".
See the API documentation for complete layer and style information.
mapSpain::esp_get_tiles() downloads map tiles.
terra::RGB() identifies RGB channels.
terra::plotRGB() and tidyterra::geom_spatraster_rgb() plot RGB rasters.
# With a bounding box pict <- catr_wms_get_layer( c(222500, 4019500, 223700, 4020700), srs = 25830, what = "parcel" ) library(mapSpain) library(ggplot2) library(tidyterra) ggplot() + geom_spatraster_rgb(data = pict) # With a spatial object parcels <- catr_wfs_get_parcels_neigh_parcel("3662303TF3136B", srs = 25830) # Use styles parcels_img <- catr_wms_get_layer(parcels, what = "buildingpart", srs = 25830, # Same as the parcels object bbox_expand = 0.3, styles = "ELFCadastre" ) ggplot() + geom_sf(data = parcels, fill = "blue", alpha = 0.5) + geom_spatraster_rgb(data = parcels_img)# With a bounding box pict <- catr_wms_get_layer( c(222500, 4019500, 223700, 4020700), srs = 25830, what = "parcel" ) library(mapSpain) library(ggplot2) library(tidyterra) ggplot() + geom_spatraster_rgb(data = pict) # With a spatial object parcels <- catr_wfs_get_parcels_neigh_parcel("3662303TF3136B", srs = 25830) # Use styles parcels_img <- catr_wms_get_layer(parcels, what = "buildingpart", srs = 25830, # Same as the parcels object bbox_expand = 0.3, styles = "ELFCadastre" ) ggplot() + geom_sf(data = parcels, fill = "blue", alpha = 0.5) + geom_spatraster_rgb(data = parcels_img)
Build and run a WFS INSPIRE request. This function supports the package's WFS functions and is also available for querying other cadastral or INSPIRE resources.
inspire_wfs_get( scheme = "https", hostname = "ovc.catastro.meh.es", path = "INSPIRE/wfsCP.aspx", query = list(), verbose = FALSE )inspire_wfs_get( scheme = "https", hostname = "ovc.catastro.meh.es", path = "INSPIRE/wfsCP.aspx", query = list(), verbose = FALSE )
scheme |
Character string specifying the protocol used to access the resource. |
hostname |
Character string specifying the resource host. |
path |
Character string specifying the resource path on the host. |
query |
Named list of query parameters and their values. |
verbose |
Logical. If |
The function constructs a request URL from its components, downloads the result to a temporary cache and reports WFS exceptions. See Examples.
A character string containing the downloaded file path. Returns NULL if
the request fails.
Query data from WFS INSPIRE services:
catr_wfs_get_address_bbox(),
catr_wfs_get_buildings_bbox(),
catr_wfs_get_parcels_bbox()
# 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() }# 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() }