diff --git a/DESCRIPTION b/DESCRIPTION index d1dbdd86..d03ccd33 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mapSpain Title: Administrative Boundaries of Spain -Version: 0.9.1 +Version: 0.9.1.9000 Authors@R: person("Diego", "Hernangómez", , "diego.hernangomezherrero@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0001-8457-4658", affiliation = "rOpenSpain")) diff --git a/NEWS.md b/NEWS.md index 32d6871c..3581ddc6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# mapSpain (development version) + +- **SIANE 2024 Update**: Adapt functions to new databases. +- Improve dictionaries: `esp_dict_region_code()` and `esp_dict_translate()`. + # mapSpain 0.9.1 - Update actions and docs. diff --git a/R/esp_dict.R b/R/esp_dict.R index 96c0fdf8..6933cd99 100644 --- a/R/esp_dict.R +++ b/R/esp_dict.R @@ -61,6 +61,20 @@ #' esp_dict_region_code <- function(sourcevar, origin = "text", destination = "text") { + # Manually replace + sourcevar <- gsub("Ciudad de ceuta", "Ceuta", sourcevar, + ignore.case = TRUE + ) + sourcevar <- gsub("Ciudad de melilla", "Melilla", sourcevar, + ignore.case = TRUE + ) + sourcevar <- gsub("sta. cruz", "Santa Cruz", sourcevar, + ignore.case = TRUE + ) + sourcevar <- gsub("sta cruz", "Santa Cruz", sourcevar, + ignore.case = TRUE + ) + initsourcevar <- sourcevar validvars <- c("text", "nuts", "iso2", "codauto", "cpro") @@ -245,6 +259,20 @@ esp_dict_translate <- function(sourcevar, lang = "en", all = FALSE) { names_full[grep("name", dict$variable), c("key", "value")] ) + # Manually replace + sourcevar <- gsub("Ciudad de ceuta", "Ceuta", sourcevar, + ignore.case = TRUE + ) + sourcevar <- gsub("Ciudad de melilla", "Melilla", sourcevar, + ignore.case = TRUE + ) + sourcevar <- gsub("sta. cruz", "Santa Cruz", sourcevar, + ignore.case = TRUE + ) + sourcevar <- gsub("sta cruz", "Santa Cruz", sourcevar, + ignore.case = TRUE + ) + tokeys <- countrycode::countrycode(sourcevar, origin = "value", destination = "key", diff --git a/R/esp_get_ccaa.R b/R/esp_get_ccaa.R index dcc505ba..89d10593 100644 --- a/R/esp_get_ccaa.R +++ b/R/esp_get_ccaa.R @@ -194,7 +194,7 @@ esp_get_ccaa_siane <- function(ccaa = NULL, year = Sys.Date(), epsg = "4258", initcols <- colnames(sf::st_drop_geometry(data_sf)) # Add codauto - data_sf$lab <- data_sf$nombres_f + data_sf$lab <- data_sf$rotulo data_sf$lab <- gsub("Ciudad de ", "", data_sf$lab, fixed = TRUE) data_sf$lab <- gsub("/Catalunya", "", data_sf$lab) diff --git a/R/esp_get_hypsobath.R b/R/esp_get_hypsobath.R index 336077d1..9defbde6 100644 --- a/R/esp_get_hypsobath.R +++ b/R/esp_get_hypsobath.R @@ -154,4 +154,5 @@ esp_get_hypsobath <- function(epsg = "4258", cache = TRUE, update_cache = FALSE, ) data_sf <- sf::st_transform(data_sf, as.double(init_epsg)) + data_sf } diff --git a/R/utils_siane.R b/R/utils_siane.R index 62fb65e8..96c0a77f 100644 --- a/R/utils_siane.R +++ b/R/utils_siane.R @@ -235,6 +235,11 @@ esp_hlp_get_siane <- function(type, # Transform and bind data_sf2 <- sf::st_transform(data_sf2, sf::st_crs(data_sf1)) + if (ncol(data_sf1) != ncol(data_sf2)) { + data_sf2[, setdiff(names(data_sf1), names(data_sf2))] <- NA + } + + data_sf <- rbind(data_sf1, data_sf2) } else { if (verbose) { @@ -243,6 +248,14 @@ esp_hlp_get_siane <- function(type, data_sf <- data_sf1 } # Date management + # Need to adjust on 2024 dist + if (type %in% c( + "roads", "riverline", "riverarea", + "orogarea", "orogline" + )) { + data_sf$fecha_baja <- NA + } + mindate <- min(data_sf$fecha_alta) maxdate <- Sys.Date() year <- as.character(year) diff --git a/data/esp_codelist.rda b/data/esp_codelist.rda index 6bbfa5d0..7e777386 100644 Binary files a/data/esp_codelist.rda and b/data/esp_codelist.rda differ diff --git a/data/esp_tiles_providers.rda b/data/esp_tiles_providers.rda index 68a230cc..2df47cc3 100644 Binary files a/data/esp_tiles_providers.rda and b/data/esp_tiles_providers.rda differ diff --git a/data/leaflet.providersESP.df.rda b/data/leaflet.providersESP.df.rda index 7246d707..228f72fb 100644 Binary files a/data/leaflet.providersESP.df.rda and b/data/leaflet.providersESP.df.rda differ diff --git a/img/README-static-1.png b/img/README-static-1.png index 50591e1c..5c679a21 100644 Binary files a/img/README-static-1.png and b/img/README-static-1.png differ diff --git a/tests/testthat/test-esp_dict.R b/tests/testthat/test-esp_dict.R index 4a6b1d4f..05a3d493 100644 --- a/tests/testthat/test-esp_dict.R +++ b/tests/testthat/test-esp_dict.R @@ -16,7 +16,10 @@ test_that("Testing dict", { "Ciudad Autónoma de Ceuta", "Ciudad Autónoma de Melilla", "Región de Murcia", - "Principado de Asturias" + "Principado de Asturias", + "Ciudad de Ceuta", + "Ciudad de Melilla", + "Sta. Cruz de Tenerife" ), destination = "cpro" ) @@ -73,4 +76,18 @@ test_that("Testing dict", { expect_false(all(vals == test)) expect_true(all(vals == esp_dict_translate(test, "es"))) + expect_silent( + esp_dict_translate( + c( + "Ciudad Autónoma de Ceuta", + "Ciudad Autónoma de Melilla", + "Región de Murcia", + "Principado de Asturias", + "Ciudad de Ceuta", + "Ciudad de Melilla", + "Sta. Cruz de Tenerife" + ), + lang = "eu" + ) + ) }) diff --git a/vignettes/basic-1.png b/vignettes/basic-1.png index 8f38a224..d08708ca 100644 Binary files a/vignettes/basic-1.png and b/vignettes/basic-1.png differ diff --git a/vignettes/basic2-1.png b/vignettes/basic2-1.png index 5fd8d381..2a4bedf4 100644 Binary files a/vignettes/basic2-1.png and b/vignettes/basic2-1.png differ diff --git a/vignettes/basic3-1.png b/vignettes/basic3-1.png index a1f2526b..1f579a32 100644 Binary files a/vignettes/basic3-1.png and b/vignettes/basic3-1.png differ diff --git a/vignettes/choro-1.png b/vignettes/choro-1.png index dae89b86..44bbc638 100644 Binary files a/vignettes/choro-1.png and b/vignettes/choro-1.png differ diff --git a/vignettes/giscoR-1.png b/vignettes/giscoR-1.png index 78c53abd..717970af 100644 Binary files a/vignettes/giscoR-1.png and b/vignettes/giscoR-1.png differ diff --git a/vignettes/thematic-1.png b/vignettes/thematic-1.png index ba43d3a2..22577de8 100644 Binary files a/vignettes/thematic-1.png and b/vignettes/thematic-1.png differ