Skip to content

Commit

Permalink
Update docs with pkgdev
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 19, 2024
1 parent 46347a7 commit cc9535f
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 61 deletions.
12 changes: 8 additions & 4 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -----------------------------------------------------------
# CITATION file created with {cffr} R package, v0.5.0
# CITATION file created with {cffr} R package, v1.0.0
# See also: https://docs.ropensci.org/cffr/
# -----------------------------------------------------------

Expand Down Expand Up @@ -67,11 +67,10 @@ references:
url: https://www.R-project.org/
authors:
- name: R Core Team
location:
name: Vienna, Austria
year: '2024'
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'
version: '>= 3.6'
- type: software
title: dplyr
Expand Down Expand Up @@ -161,6 +160,7 @@ references:
authors:
- family-names: Gagolewski
given-names: Marek
orcid: https://orcid.org/0000-0003-0637-6028
- family-names: Tartanus
given-names: Bartek
- family-names: Unicode
Expand Down Expand Up @@ -244,6 +244,10 @@ references:
- family-names: Dunnington
given-names: Dewey
orcid: https://orcid.org/0000-0002-9415-4582
- family-names: Brand
given-names: Teun
name-particle: van den
orcid: https://orcid.org/0000-0002-9335-7468
year: '2024'
- type: software
title: knitr
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ Alternatively, you can install the developing version of **CatastRo**
with:

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

## Package API
Expand All @@ -67,8 +66,9 @@ references using the
service.

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

### INSPIRE

Expand All @@ -77,8 +77,8 @@ These functions return spatial object (on the formats provided by the
INSPIRE](https://www.catastro.minhap.es/webinspire/index.html) service.

Note that the coverage of this service is 95% of the Spanish territory,
excluding Basque Country and Navarre that have their own independent
cadastral offices.
<u>excluding Basque Country and Navarre</u> that have their own
independent cadastral offices.

There are three types of functions, each one querying a different
service:
Expand All @@ -94,18 +94,18 @@ 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` 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.
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**.
[**terra**](https://rspatial.github.io/terra/reference/terra-package.html).

There is a single function for querying this service:
`catr_wms_get_layer()`.
Expand Down
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)",
"runtimePlatform": "R version 4.3.3 (2024-02-29 ucrt)",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -271,7 +271,7 @@
},
"SystemRequirements": null
},
"fileSize": "866.161KB",
"fileSize": "864.519KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down
Binary file modified data/catr_srs_values.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion inst/schemaorg.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)",
"runtimePlatform": "R version 4.3.3 (2024-02-29 ucrt)",
"version": "0.3.0.9000"
},
{
Expand Down
Binary file modified man/figures/README-atom-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-wfs-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-wms-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 20 additions & 20 deletions vignettes/CatastRo.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,14 @@ stadium <- catr_wfs_get_buildings_bbox(
c(-3.6891446916, 40.4523311971, -3.687462138, 40.4538643165),
srs = 4326
)
#> Error in catr_hlp_dwnload(api_entry, filename, cache_dir = tempdir(), :
#> Execution halted

# Now extract cadastral parcels. We can use spatial objects on the query

stadium_parcel <- catr_wfs_get_parcels_bbox(stadium)
#> Error in eval(expr, envir, enclos): object 'stadium' not found

# Project for tiles

stadium_parcel_pr <- sf::st_transform(stadium_parcel, 25830)
#> Error in eval(expr, envir, enclos): object 'stadium_parcel' not found

# Extract imagery: Labels of the parcel

Expand All @@ -107,7 +103,6 @@ labs <- catr_wms_get_layer(stadium_parcel_pr,
styles = "BoundariesOnly",
srs = 25830
)
#> Error in eval(expr, envir, enclos): object 'stadium_parcel_pr' not found

# Plot
library(ggplot2)
Expand All @@ -118,10 +113,13 @@ ggplot() +
geom_sf(data = stadium_parcel_pr, fill = NA, col = "red", linewidth = 2) +
geom_sf(data = stadium, fill = "red", alpha = .5) +
coord_sf(crs = 25830)
#> Error in `geom_spatraster_rgb()`:
#> ! `tidyterra::geom_spatraster_rgb()` only works with <SpatRaster> objects, not <function>. See `?terra::vect()`
```

<div class="figure">
<img src="./santbernabeu-1.png" alt="Example: Santiago Bernabeu" width="100%" />
<p class="caption">Example: Santiago Bernabeu</p>
</div>

### Thematic maps

We can create also thematic maps using the information available on the spatial
Expand Down Expand Up @@ -153,14 +151,15 @@ Granada in the Cadastre, and we would download the buildings with

```r
city_catr_code <- catr_get_code_from_coords(city)
#> Error in catr_hlp_dwnload(api_entry, filename, cache_dir, verbose, update_cache = FALSE, :
#> Execution halted

city_catr_code
#> Error in eval(expr, envir, enclos): object 'city_catr_code' not found
#> # A tibble: 1 × 12
#> munic catr_to catr_munic catrcode cpro cmun inecode nm cd cmc cp
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 GRANA… 18 900 18900 18 087 18087 GRAN… 18 900 18
#> # ℹ 1 more variable: cm <chr>

city_bu <- catr_atom_get_buildings(city_catr_code$catrcode)
#> Error in eval(expr, envir, enclos): object 'city_catr_code' not found
```

Next step for creating the visualization is to limit the analysis to a circle of
Expand All @@ -173,40 +172,38 @@ buff <- city %>%
st_transform(st_crs(city_bu)) %>%
# Buffer
st_buffer(1500)
#> Error: object 'city_bu' not found


# Cut buildings

dataviz <- st_intersection(city_bu, buff)
#> Error in eval(expr, envir, enclos): object 'city_bu' not found

ggplot(dataviz) +
geom_sf()
#> Error in eval(expr, envir, enclos): object 'dataviz' not found
```

<div class="figure">
<img src="./minimal-1.png" alt="Minimal cadastral map of Granada" width="100%" />
<p class="caption">Minimal cadastral map of Granada</p>
</div>

Let's extract now the construction year, available in the column `beginning`:


```r
# Extract 4 initial positions
year <- substr(dataviz$beginning, 1, 4)
#> Error in eval(expr, envir, enclos): object 'dataviz' not found

# Replace all that doesn't look as a number with 0000
year[!(year %in% 0:2500)] <- "0000"
#> Error: object 'year' not found


# To numeric
year <- as.integer(year)
#> Error in eval(expr, envir, enclos): object 'year' not found

# New column
dataviz <- dataviz %>%
mutate(year = year)
#> Error in eval(expr, envir, enclos): object 'dataviz' not found
```

Last step is to create groups based on the year and create the data
Expand All @@ -220,7 +217,6 @@ dataviz <- dataviz %>%
breaks = c(0, seq(1900, 2030, by = 10)),
dig.lab = 4
))
#> Error in eval(expr, envir, enclos): object 'dataviz' not found


ggplot(dataviz) +
Expand Down Expand Up @@ -250,9 +246,13 @@ ggplot(dataviz) +
),
plot.margin = margin(r = 40, l = 40)
)
#> Error in eval(expr, envir, enclos): object 'dataviz' not found
```

<div class="figure">
<img src="./dataviz-1.png" alt="Granada: Urban growth" width="100%" />
<p class="caption">Granada: Urban growth</p>
</div>

## References

- Royé D (2019). "Visualize urban growth."
Expand Down
Binary file modified vignettes/dataviz-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/minimal-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 40 additions & 23 deletions vignettes/ovcservice.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ result <- catr_ovc_get_rccoor(
lon = -3.45624183836806,
srs = "4230"
)
#> Error in `httr2::req_perform()` at project/R/ovc_rccoor.R:85:3:
#> ! Failed to perform HTTP request.
#> Caused by error in `curl::curl_fetch_memory()`:
#> ! Recv failure: Connection reset by peer
```


```
#> Error in eval(expr, envir, enclos): object 'result' not found
```

|refcat |address |pc.pc1 |pc.pc2 | geo.xcen| geo.ycen|geo.srs |ldt |
|:--------------|:----------------------------------------------------------------------------------------------------|:-------|:-------|---------:|--------:|:---------|:----------------------------------------------------------------------------------------------------|
|13077A01800039 |DS DISEMINADO Polígono 18 Parcela 39 000100200VH67C EL TIRADERO. SANTA CRUZ DE MUDELA (CIUDAD REAL) |13077A0 |1800039 | -3.456242| 38.61966|EPSG:4230 |DS DISEMINADO Polígono 18 Parcela 39 000100200VH67C EL TIRADERO. SANTA CRUZ DE MUDELA (CIUDAD REAL) |



The function accept as a SRS argument the following values:

Expand Down Expand Up @@ -124,12 +123,17 @@ catr_ovc_get_rccoor_distancia(
srs = "4230"
) %>%
knitr::kable()
#> Error in `httr2::req_perform()` at project/R/ovc_rccoor_distancia.R:97:3:
#> ! Failed to perform HTTP request.
#> Caused by error in `curl::curl_fetch_memory()`:
#> ! Recv failure: Connection reset by peer
```



| geo.xcen| geo.ycen|geo.srs |refcat |address |cmun_ine |pc.pc1 |pc.pc2 |dt.loine.cp |dt.loine.cm |dt.lourb.dir.cv |dt.lourb.dir.pnp |ldt |dis |
|---------:|--------:|:---------|:--------------|:-----------------------------------------------|:--------|:-------|:-------|:-----------|:-----------|:---------------|:----------------|:-----------------------------------------------|:-----|
| -5.663408| 40.96002|EPSG:4230 |5877501TL7357F |AV REYES DE ESPAÑA 1 SALAMANCA (SALAMANCA) |37274 |5877501 |TL7357F |37 |274 |643 |1 |AV REYES DE ESPAÑA 1 SALAMANCA (SALAMANCA) |21.81 |
| -5.663408| 40.96002|EPSG:4230 |5778706TL7357H |AV REYES DE ESPAÑA 2 N2-4 SALAMANCA (SALAMANCA) |37274 |5778706 |TL7357H |37 |274 |643 |2 |AV REYES DE ESPAÑA 2 N2-4 SALAMANCA (SALAMANCA) |23.18 |



## Geocoding a Cadastral Reference

The opposite query is possible as well. Being given to the function
Expand All @@ -146,12 +150,16 @@ catr_ovc_get_cpmrc(
municipality = "SANTA CRUZ DE MUDELA"
) %>%
knitr::kable()
#> Error in `httr2::req_perform()` at project/R/ovc_cpmrc.R:104:3:
#> ! Failed to perform HTTP request.
#> Caused by error in `curl::curl_fetch_memory()`:
#> ! Recv failure: Connection reset by peer
```



| xcoord| ycoord|refcat |address |pc.pc1 |pc.pc2 |geo.xcen |geo.ycen |geo.srs |ldt |
|---------:|--------:|:--------------|:----------------------------------------------------------------------------------------------------|:-------|:-------|:-----------------|:----------------|:---------|:----------------------------------------------------------------------------------------------------|
| -3.456242| 38.61966|13077A01800039 |DS DISEMINADO Polígono 18 Parcela 39 000100200VH67C EL TIRADERO. SANTA CRUZ DE MUDELA (CIUDAD REAL) |13077A0 |1800039 |-3.45624183836806 |38.6196566583596 |EPSG:4230 |DS DISEMINADO Polígono 18 Parcela 39 000100200VH67C EL TIRADERO. SANTA CRUZ DE MUDELA (CIUDAD REAL) |



Neither the `province` nor `municipality` are required to be passed to the
function, unless the argument `municipality` is not `NULL`, in that case the
argument `province` is needed to be passed. If it is passed a value to the
Expand All @@ -165,21 +173,30 @@ catr_ovc_get_cpmrc(
municipality = "SANTA CRUZ DE MUDELA"
) %>%
knitr::kable()
#> Error in `httr2::req_perform()` at project/R/ovc_cpmrc.R:104:3:
#> ! Failed to perform HTTP request.
#> Caused by error in `curl::curl_fetch_memory()`:
#> ! Recv failure: Connection reset by peer
#> Error code: 11. LA PROVINCIA ES OBLIGATORIA
```



|refcat |geo.srs |
|:--------------|:---------|
|13077A01800039 |EPSG:4326 |



When using only `rc` the result is provided as expected:


```r
# No warning, get the result
catr_ovc_get_cpmrc(rc = "13077A01800039") %>%
knitr::kable()
#> Error in `httr2::req_perform()` at project/R/ovc_cpmrc.R:104:3:
#> ! Failed to perform HTTP request.
#> Caused by error in `curl::curl_fetch_memory()`:
#> ! Recv failure: Connection reset by peer
```



| xcoord| ycoord|refcat |address |pc.pc1 |pc.pc2 |geo.xcen |geo.ycen |geo.srs |ldt |
|---------:|--------:|:--------------|:----------------------------------------------------------------------------------------------------|:-------|:-------|:-----------------|:----------------|:---------|:----------------------------------------------------------------------------------------------------|
| -3.457532| 38.61843|13077A01800039 |DS DISEMINADO Polígono 18 Parcela 39 000100200VH67C EL TIRADERO. SANTA CRUZ DE MUDELA (CIUDAD REAL) |13077A0 |1800039 |-3.45753233627867 |38.6184314024661 |EPSG:4326 |DS DISEMINADO Polígono 18 Parcela 39 000100200VH67C EL TIRADERO. SANTA CRUZ DE MUDELA (CIUDAD REAL) |


Binary file modified vignettes/santbernabeu-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cc9535f

Please sign in to comment.