##################
# MAPPE ZONE OMI #
##################
masteRfun::load_pkgs('data.table', 'dplyr', 'fst', 'rmapshaper', 'sf')
# crea mappe italia completa CAP e UTB
for(tz in c('UTB', 'CAP')){
message('\nElaboro zona ', tz, '...')
message(' - Leggo codici...')
y <- read_fst(file.path(data_tpath, 'sezioni'), columns = c('SZN', tz), as.data.table = TRUE)
y <- y[!is.na(get(tz))]
message(' - Leggo confini sezioni...')
bnd <- readRDS(file.path(bnd_path, 'SZN', pct, '0'))
message(' - Aggiungo codici...')
bnd <- bnd %>% inner_join(y)
message(' - Cancello confini interni...')
bnd <- bnd %>% ms_dissolve(!!tz)
message(' - Salvo...')
simplify_bnd(bnd, '0', file.path(bnd_path, tz))
}
# crea mappe italia completa OMI (servono piu' memoria di quella installata)
y <- read_fst(file.path(data_tpath, 'sezioni'), columns = c('SZN', 'OMI'), as.data.table = TRUE)
y <- y[!is.na(OMI)]
for(k in 2:5){
pct <- paste0('s', k, '0')
message('\nElaboro percentuale ', pct, '...')
message(' - Leggo confini sezioni...')
bnd <- readRDS(file.path(bnd_path, 'SZN', pct, '0'))
message(' - Aggiungo codici...')
bnd <- bnd %>% inner_join(y)
message(' - Cancello confini interni...')
bnd <- bnd %>% ms_dissolve('OMI')
message(' - Salvo...')
saveRDS(bnd, file.path(bnd_path, 'OMI', pct, '0'))
}
# crea zone singole (salvate in tz)
for(tz in c('UTB', 'CAP', 'OMI')){
bnd <- readRDS(file.path(bnd_path, tz, 's00', '0'))
for(idx in 1:nrow(bnd)){
message('\nElaboro tipo ', tz, ': zona ' , idx, '...')
simplify_bnd(bnd[idx,], bnd[idx,] %>% st_drop_geometry(), file.path(bnd_path, tz))
}
}
# crea zone singole con sezioni (salvate in SZN)
for(tz in c('UTB', 'CAP', 'OMI')){
bnd <- readRDS(file.path(bnd_path, tz, 's00', '0'))
for(idx in 1:nrow(bnd)){
message('\nElaboro tipo ', tz, ': zona ' , idx, '...')
simplify_bnd(bnd[idx,], bnd[idx,] %>% st_drop_geometry(), file.path(bnd_path, tz))
}
}
gc()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.