Skip to content

Commit

Permalink
Merge pull request #112 from rOpenSpain/dist2024
Browse files Browse the repository at this point in the history
Adapt to SIANE 2024
  • Loading branch information
dieghernan authored Aug 2, 2024
2 parents 551cb7b + 7c3e3f4 commit a78aeb2
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-8457-4658", affiliation = "rOpenSpain"))
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
28 changes: 28 additions & 0 deletions R/esp_dict.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@
#'
esp_dict_region_code <- function(sourcevar, origin = "text",

Check warning on line 62 in R/esp_dict.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/esp_dict.R,line=62,col=1,[cyclocomp_linter] Functions should have cyclomatic complexity of less than 15, this has 18.
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")
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion R/esp_get_ccaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions R/esp_get_hypsobath.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
13 changes: 13 additions & 0 deletions R/utils_siane.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
Binary file modified data/esp_codelist.rda
Binary file not shown.
Binary file modified data/esp_tiles_providers.rda
Binary file not shown.
Binary file modified data/leaflet.providersESP.df.rda
Binary file not shown.
Binary file modified img/README-static-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion tests/testthat/test-esp_dict.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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"
)
)
})
Binary file modified vignettes/basic-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/basic2-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/basic3-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/choro-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/giscoR-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/thematic-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 a78aeb2

Please sign in to comment.