-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathREADME.Rmd
228 lines (165 loc) · 6.89 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{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)
```
# CatastRo <a href="https://ropenspain.github.io/CatastRo/"><img src="man/figures/logo.png" align="right" height="139"/></a>
<!-- badges: start -->
[![rOS-badge](https://ropenspain.github.io/rostemplate/reference/figures/ropenspain-badge.svg)](https://ropenspain.es/)
[![CRAN-status](https://www.r-pkg.org/badges/version/CatastRo)](https://CRAN.R-project.org/package=CatastRo)
[![CRAN-results](https://badges.cranchecks.info/worst/CatastRo.svg)](https://cran.r-project.org/web/checks/check_results_CatastRo.html)
[![Downloads](https://cranlogs.r-pkg.org/badges/CatastRo)](https://CRAN.R-project.org/package=CatastRo)
[![r-universe](https://ropenspain.r-universe.dev/badges/CatastRo)](https://ropenspain.r-universe.dev/CatastRo)
[![R-CMD-check](https://github.com/rOpenSpain/CatastRo/actions/workflows/roscron-check-standard.yaml/badge.svg)](https://github.com/rOpenSpain/CatastRo/actions/workflows/roscron-check-standard.yaml)
[![R-hub](https://github.com/rOpenSpain/CatastRo/actions/workflows/rhub.yaml/badge.svg)](https://github.com/rOpenSpain/CatastRo/actions/workflows/rhub.yaml)
[![codecov](https://codecov.io/gh/rOpenSpain/CatastRo/graph/badge.svg?token=KPPwTkZjW6)](https://app.codecov.io/gh/rOpenSpain/CatastRo)
[![DOI](https://img.shields.io/badge/DOI-10.32614/CRAN.package.CatastRo-blue)](https://doi.org/10.32614/CRAN.package.CatastRo)
[![Project Status: Active -- The project has reached a stable, usable state and
is being actively
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
<!-- badges: end -->
**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)
```
## 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/).