MyNixOS website logo
Description

Interface to the API 'Sede Electronica Del Catastro'.

Access public spatial data available under the 'INSPIRE' directive. Tools for downloading references and addresses of properties, as well as map images.

CatastRo

rOS-badge CRAN-status CRAN-results Downloads r-universe R-CMD-check R-hub codecov DOI Project Status: Active – The project has reached a stable, usablestate and is being activelydeveloped.

CatastRo is a package that provide access to different API services of the Spanish Cadastre. With CatastRo it is possible to download spatial objects (as buildings or cadastral parcels), maps and geocode cadastral references.

Installation

Install CatastRo from CRAN:

install.packages("CatastRo")

You can install the developing version of CatastRo using the r-universe:

# Install CatastRo in R:
install.packages("CatastRo",
  repos = c(
    "https://ropenspain.r-universe.dev",
    "https://cloud.r-project.org"
  )
)

Alternatively, you can install the developing version of CatastRo with:

remotes::install_github("rOpenSpain/CatastRo", dependencies = TRUE)

Package API

The functions of CatastRo are organized by API endpoint. The package naming convention is catr_*api*_*description*.

OVCCoordenadas

These functions allow to geocode and reverse geocode cadastral references using the OVCCoordenadas service.

These functions are named catr_ovc_get_* and returns a tibble, as provided by the package tibble. See vignette("ovcservice", package = "CatastRo") where these functions are described.

INSPIRE

These functions return spatial object (on the formats provided by the sf or terra using the Catastro INSPIRE service.

Note that the coverage of this service is 95% of the Spanish territory, excluding Basque Country and Navarre[^1] that have their own independent cadastral offices.

There are three types of functions, each one querying a different service:

ATOM service

The ATOM service allows to batch-download vector objects of different cadastral elements for a specific municipality. The result is provided as sf objects (See sf package).

These functions are named catr_atom_get_xxx.

WFS service

The WFS service allows to download vector objects of specific cadastral elements. The result is provided as sf class objects (see sf package). Note that there are some limitations on the extension and number of elements to query. For batch-downloading the ATOM service is preferred.

These functions are named catr_wms_get_xxx.

WMS service

This service allows to download georeferenced images of different cadastral elements. The result is a raster on the format provides by terra.

There is a single function for querying this service: catr_wms_get_layer().

Terms and conditions of use

Please check the downloading provisions of the service.

Examples

This script highlights some features of CatastRo :

Geocode a cadastral reference

library(CatastRo)

catr_ovc_get_cpmrc(rc = "13077A01800039")
#> # A tibble: 1 × 10
#>   xcoord ycoord refcat     address pc.pc1 pc.pc2 geo.xcen geo.ycen geo.srs ldt  
#>    <dbl>  <dbl> <chr>      <chr>   <chr>  <chr>  <chr>    <chr>    <chr>   <chr>
#> 1  -3.46   38.6 13077A018… DS DIS… 13077… 18000… -3.4575… 38.6184… EPSG:4… DS D…

Extract a cadastral reference from a given set of coordinates

catr_ovc_get_rccoor(
  lat = 38.6196566583596,
  lon = -3.45624183836806,
  srs = "4230"
)
#> # A tibble: 1 × 8
#>   refcat         address           pc.pc1 pc.pc2 geo.xcen geo.ycen geo.srs ldt  
#>   <chr>          <chr>             <chr>  <chr>     <dbl>    <dbl> <chr>   <chr>
#> 1 13077A01800039 DS DISEMINADO  P… 13077… 18000…    -3.46     38.6 EPSG:4… DS D…

Extract geometries using the ATOM service

bu <- catr_atom_get_buildings("Nava de la Asuncion", to = "Segovia")


# Map
library(ggplot2)

ggplot(bu) +
  geom_sf(aes(fill = currentUse), col = NA) +
  coord_sf(
    xlim = c(374500, 375500),
    ylim = c(4556500, 4557500)
  ) +
  scale_fill_manual(values = hcl.colors(6, "Dark 3")) +
  theme_minimal() +
  ggtitle("Nava de la Asunción, Segovia")

Extract geometries using the WFS service

wfs_get_buildings <- catr_wfs_get_buildings_bbox(
  c(-5.569, 42.598, -5.564, 42.601),
  srs = 4326
)

# Map
ggplot(wfs_get_buildings) +
  geom_sf() +
  ggtitle("Leon Cathedral, Spain")

Extract maps using the WMS service

# For tiles better project

wfs_get_buildings_pr <- sf::st_transform(wfs_get_buildings, 25830)

wms_bu <- catr_wms_get_layer(wfs_get_buildings_pr,
  srs = 25830,
  bbox_expand = 0.2
)

# Map
# Load tidyterra
library(tidyterra)
ggplot() +
  geom_spatraster_rgb(data = wms_bu) +
  geom_sf(data = wfs_get_buildings_pr, fill = "red", alpha = 0.6)

A note on caching

Some data sets and tiles may have a size larger than 50MB. You can use CatastRo to create your own local repository at a given local directory passing the following option:

catr_set_cache_dir("./path/to/location")

When this option is set, CatastRo would look for the cached file and it will load it, speeding up the process.

Citation

Delgado Panadero Á, Hernangómez D (2024). CatastRo: Interface to the API Sede Electrónica Del Catastro. doi:10.5281/zenodo.6044091, https://ropenspain.github.io/CatastRo/.

A BibTeX entry for LaTeX users is:

@Manual{R-catastro,
  title = {{CatastRo}: Interface to the {API} Sede Electrónica Del Catastro},
  author = {Ángel {Delgado Panadero} and Diego Hernangómez},
  year = {2024},
  version = {0.4.0},
  url = {https://ropenspain.github.io/CatastRo/},
  doi = {10.5281/zenodo.6044091},
  abstract = {Access public spatial data available under the INSPIRE directive. Tools for downloading references and addresses of properties, as well as map images.},
}

Contribute

Check the GitHub page for source code.

[^1]: The package CatastRoNav provides access to the Cadastre of Navarre, with similar functionalities than CatastRo.

Metadata

Version

0.4.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows