catastroprovince: catastroprovince

Description Usage Arguments Value Examples

View source: R/catastroprovince.R

Description

catastroprovince is a function that download all the catastro data types from a list of municipalities within a province and exports the data to a gpkg. The buildings and buildingparts contain both heigth estimation (based on Hfloor) and Municipality

Usage

1
2
3
4
5
6
7
8
9
catastroprovince(
  province = "Melilla",
  catastropush = "http://www.catastro.minhap.es/INSPIRE/buildings/ES.SDGC.bu.atom.xml",
  tempdir = "./temp/",
  output = "./output/",
  rpush = FALSE,
  overwrite = TRUE,
  Hfloor = 3
)

Arguments

province

–> is a string with the name of the provoince of interest (can be checked with FeedProvinces())

catastropush

–> url of the atom service (xml url)

tempdir

–> directory where temporal files are unziped and readed

output

–> directory where gpkg is exported

rpush

–> TRUE if you want a notification when process is over (use just if configured)

overwrite

–> TRUE if you want to overwrite gpkg file in case it exist

Hfloor

–> set the desired height (m) for each floor above the ground (to estimate building height)

Value

gpkgname as the directory of the gpkg file created after the process

Examples

 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
## Not run: 
#-------------------------------------------------------------------------------
# Catch Provinces Names in atom service
FeedProvinces(catastropush)

# Create the list of Provinces of interest
provinceslist <- c("Ceuta","Melilla")

#-------------------------------------------------------------------------------
# +++++++++++++++++++++ LINUX TESTS ++++++++++++++++++++++++++++++++++++++++++++
#-------------------------------------------------------------------------------
# TEST 1 --> Download Full province
#-------------------------------------------------------------------------------
catastroprovince('Ceuta', catastropush, tempfolder, output, rpush = TRUE, overwrite = FALSE)

#---------------------------------------------------------------------------
# TEST 2 --> Dowload Provinces in Parallel
#-------------------------------------------------------------------------------
cl <- parallel::makeCluster(ncores, type="FORK")
doParallel::registerDoParallel(cl)

foreach(i=provinceslist) %dopar% {
    catastroprovince(i,catastropush, tempdir, output, rpush, overwrite)}

stopCluster(cl)

#-------------------------------------------------------------------------------
# ++++++++++++++++++++++ WINDOWS TESTS +++++++++++++++++++++++++++++++++++++++++
#-------------------------------------------------------------------------------
# TEST 1 --> Download Full province
#-------------------------------------------------------------------------------
catastroprovince('Melilla',catastropush, tempfolder, output, rpush = TRUE, overwrite = TRUE)

#---------------------------------------------------------------------------
# TEST 2 --> Dowload Provinces in Parallel
#-------------------------------------------------------------------------------
cl <- parallel::makeCluster(ncores, type="PSOCK")
doParallel::registerDoParallel(cl)
clusterEvalQ(cl, library("CatastroDownloader")) # load libraries
clusterExport(cl, c('catastropush', 'output', 'tempdir', 'ncores'))

foreach(i=provinceslist) %dopar% {
    catastroprovince(i,catastropush, tempdir, output, rpush, overwrite)}

stopCluster(cl)

#-------------------------------------------------------------------------------
# ++++++++++++++++++++++ SHOW SOMETHING  +++++++++++++++++++++++++++++++++++++++++
#-------------------------------------------------------------------------------
# show some data
file <- paste0(output, 'Catastro_Ceuta_2021-01-26.gpkg')
layer <- st_read(file, 'buildingpart')
mapview(layer)
#' 
## End(Not run)

cesarkero/CatastroDownloader documentation built on Feb. 4, 2021, 7:22 a.m.