https://github.com/ropenspain/catastro
R package to query Sede Electrónica del Catastro (Spain)
https://github.com/ropenspain/catastro
catastro cran cran-r gis maps r r-package ropenspain rstats spain spatial static-tiles
Last synced: about 2 months ago
JSON representation
R package to query Sede Electrónica del Catastro (Spain)
- Host: GitHub
- URL: https://github.com/ropenspain/catastro
- Owner: rOpenSpain
- License: gpl-2.0
- Created: 2017-06-13T17:41:29.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-12-02T09:47:38.000Z (11 months ago)
- Last Synced: 2024-12-11T10:37:14.699Z (10 months ago)
- Topics: catastro, cran, cran-r, gis, maps, r, r-package, ropenspain, rstats, spain, spatial, static-tiles
- Language: R
- Homepage: http://ropenspain.github.io/CatastRo/
- Size: 89.2 MB
- Stars: 21
- Watchers: 8
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Citation: CITATION.cff
- Codemeta: codemeta.json
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
message = FALSE,
warning = FALSE,
dev = "ragg_png",
tidy = "styler",
dpi = 300,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)if (.Platform$OS.type != "windows") {
options(download.file.method = "curl", download.file.extra = "-k -L")
}library(CatastRo)
```[](https://ropenspain.es/)
[](https://CRAN.R-project.org/package=CatastRo)
[](https://cran.r-project.org/web/checks/check_results_CatastRo.html)
[](https://CRAN.R-project.org/package=CatastRo)
[](https://ropenspain.r-universe.dev/CatastRo)
[](https://github.com/rOpenSpain/CatastRo/actions/workflows/roscron-check-standard.yaml)
[](https://github.com/rOpenSpain/CatastRo/actions/workflows/rhub.yaml)
[](https://app.codecov.io/gh/rOpenSpain/CatastRo)
[](https://doi.org/10.32614/CRAN.package.CatastRo)
[](https://www.repostatus.org/#active)**CatastRo** is a package that provide access to different API services of the
[Spanish Cadastre](https://www.sedecatastro.gob.es/). With **CatastRo** it is
possible to download spatial objects (as buildings or cadastral parcels), maps
and geocode cadastral references.## Installation
Install **CatastRo** from
[**CRAN**](https://CRAN.R-project.org/package=CatastRo):```{r, eval = FALSE}
install.packages("CatastRo")
```You can install the developing version of **CatastRo** using the
[r-universe](https://ropenspain.r-universe.dev/CatastRo):```{r, eval = FALSE}
# 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:
```{r, eval = FALSE}
remotes::install_github("rOpenSpain/CatastRo", dependencies = TRUE)
```## Known issues
The SSL certificate of the Spanish Cadastre present some issues that may cause
an error when using **CatastRo** (specially on Mac OS, see issue
[#40](https://github.com/rOpenSpain/CatastRo/issues/40)):```{r,eval=FALSE}
#> ...(more lines on error)
#>
#> 1: In download.file(url, filepath, quiet = isFALSE(verbose), mode = "wb") :
#> URL 'https://www.catastro.minhafp.es/INSPIRE/Addresses/ES.SDGC.AD.atom.xml':
#> status was 'SSL peer certificate or SSH remote key was not OK'
#>
#> ...
```You can try to fix it by running this line on your session right after you start
using the package:```{r,eval=FALSE}
options(download.file.method = "curl", download.file.extra = "-k -L")
```## 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](https://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCoordenadas.asmx)
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](https://www.catastro.hacienda.gob.es/webinspire/index.html) service.Note that the coverage of this service is 95% of the Spanish territory,
[excluding Basque Country and Navarre]{.underline}[^1] that have their own
independent cadastral offices.[^1]: The package [**CatastRoNav**](https://ropenspain.github.io/CatastRoNav/)
provides access to the Cadastre of Navarre, with similar functionalities
than **CatastRo**.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**](https://r-spatial.github.io/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**](https://rspatial.github.io/terra/reference/terra-package.html).There is a single function for querying this service: `catr_wms_get_layer()`.
#### Terms and conditions of use
Please check the [downloading
provisions](https://www.catastro.hacienda.gob.es/webinspire/documentos/Licencia.pdf)
of the service.## Examples
This script highlights some features of **CatastRo** :
### Geocode a cadastral reference
```{r}
library(CatastRo)catr_ovc_get_cpmrc(rc = "13077A01800039")
```### Extract a cadastral reference from a given set of coordinates
```{r}
catr_ovc_get_rccoor(
lat = 38.6196566583596,
lon = -3.45624183836806,
srs = "4230"
)
```### Extract geometries using the ATOM service
```{r atom, fig.alt="Extracting buildings in Nava de la Asuncion with 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
```{r wfs, fig.alt="Extract Leon Cathedral with 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")
```## 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:```{r, eval = FALSE}
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
```{r echo=FALSE, results='asis'}
print(citation("CatastRo"), style = "html")
```A BibTeX entry for LaTeX users is:
```{r echo=FALSE, comment=''}
toBibtex(citation("CatastRo"))
```## Contribute
Check the GitHub page for [source
code](https://github.com/ropenspain/CatastRo/).## Contributors
All contributions to this project are gratefully acknowledged using the [`allcontributors` package](https://github.com/ropensci/allcontributors) following the [allcontributors](https://allcontributors.org) specification. Contributions of any kind are welcome!
### Code
### Issue Authors
### Issue Contributors