knitr::opts_chunk$set( collapse = TRUE, out.width = "100%" )
The goal of this library is to download the complete updated Catastro layers for a Province of Spain. Main benefits:
This packages has been tested in:
Install dependencies (libraries) in R:
# install libraries to install packages from github install.packages("devtools"); library(devtools) install_github("cesarkero/CatastroDownloader")
Please, use this library using your brain. Download just what you need and avoid constant masive downloads as it will produce overload in public servers and this can lead to restrictions for the general public. So please, be kind with the service and let us all enjoy this data. For sure, don't try parallel for masive downloads until you have checked that this is a useful tool to you.
Moreover, if you just need catastro for a single or a few municipalities, just use the QGIS compelemnt Spanish Inspire Catastral Downloader.
Enjoy.
Get the list of available Provinces in the Catastro atom service:
library(CatastroDownloader) # set parameters catastropush <- "http://www.catastro.minhap.es/INSPIRE/buildings/ES.SDGC.bu.atom.xml" # Catch Provinces Names in atom service FeedProvinces(catastropush)
This is the list of provinces at r Sys.Date()
:
[1] "Albacete" "Alicante" "Almería" "Avila" "Badajoz" "Baleares" "Barcelona" "Burgos" "Cáceres" "Cádiz"
[11] "Castellón" "Ciudad Real" "Córdoba" "Coruña" "Cuenca" "Girona" "Granada" "Guadalajara" "Huelva" "Huesca"
[21] "Jaén" "León" "Lleida" "La Rioja" "Lugo" "Madrid" "Málaga" "Murcia" "Ourense" "Oviedo"
[31] "Palencia" "Palmas (Las)" "Pontevedra" "Salamanca" "S.C. Tenerife" "Cantabria" "Segovia" "Sevilla" "Soria" "Tarragona"
[41] "Teruel" "Toledo" "Valencia" "Valladolid" "Zamora" "Zaragoza" "Cartagena" "Gijon" "Jerez Frontera" "Vigo"
[51] "Ceuta" "Melilla"
If you just need to download the catastro for a single Province use this:
# Set parameters catastropush <- "http://www.catastro.minhap.es/INSPIRE/buildings/ES.SDGC.bu.atom.xml" #url for the atom service output <- "../00_Output/" #where the .gpkg file will be stored tempdir <- "./temp/" #careful as all files inside will be removed rpush = TRUE #if you want a notification when finished (RPushbullet must be configured before) overwrite = TRUE #overwrite .gpkg if exists Hfloor = 3 #set desired height for each floor above the ground catastroprovince('Melilla', catastropush, tempdir, output, rpush = TRUE, overwrite = FALSE, Hfloor = 3)
knitr::include_graphics("./man/figures/I01.png")
To show some data within R
# show some data file <- paste0(output, 'Catastro_Ceuta_2021-01-26.gpkg') layer <- st_read(file, 'buildingpart') mapview(layer)
knitr::include_graphics("./man/figures/I06.png")
Parallel process allows to download a list of desired Provinces with just one execution of the code. Must be taken into acount that there are slight differences between the process within Linux and Windows.
# Set parameters catastropush <- "http://www.catastro.minhap.es/INSPIRE/buildings/ES.SDGC.bu.atom.xml" #url for the atom service output <- "../00_Output/" #where the .gpkg file will be stored tempdir <- "./temp/" #careful as all files inside will be removed rpush = TRUE #if you want a notification when finished (RPushbullet must be configured before) overwrite = TRUE #overwrite .gpkg if exists ncores = 16 #specify number of cores dedicated Hfloor = 3 #set desired height for each floor above the ground # Set list of provinces to download provinceslist <- c("Zamora", "Vigo") # Set parallel cl <- parallel::makeCluster(ncores, type="FORK") doParallel::registerDoParallel(cl) # Execute function foreach(i=provinceslist) %dopar% {catastroprovince(i,catastropush, tempdir, output, rpush, overwrite, Hfloor)} # Stop parallel stopCluster(cl)
# Set parameters catastropush <- "http://www.catastro.minhap.es/INSPIRE/buildings/ES.SDGC.bu.atom.xml" #url for the atom service output <- "../00_Output/" #where the .gpkg file will be stored tempdir <- "./temp/" #careful as all files inside will be removed rpush = TRUE #if you want a notification when finished (RPushbullet must be configured before) overwrite = TRUE #overwrite .gpkg if exists ncores = 16 #specify number of cores dedicated Hfloor = 3 #set desired height for each floor above the ground # Set list of provinces to download provinceslist <- c("Zamora", "Vigo") # Set parallel cl <- parallel::makeCluster(ncores, type="PSOCK") doParallel::registerDoParallel(cl) clusterEvalQ(cl, library("CatastroDownloader")) # load libraries clusterExport(cl, c('catastropush', 'output', 'tempdir', 'ncores')) # Execute function foreach(i=provinceslist) %dopar% {catastroprovince(i,catastropush, tempdir, output, rpush, overwrite, Hfloor)} # Stop parallel stopCluster(cl)
If you have previously configured rpushbullet you will get a notification in your devices when the process in completed.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.