Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to SIANE 2024 #112

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -59,8 +59,22 @@
#' esp_dict_region_code(valsmix, destination = "iso2")
#' }
#'
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 @@
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 @@ -92,7 +92,7 @@
#' ) +
#' theme(panel.background = element_rect(fill = "#C7E7FB"))
#' }
esp_get_ccaa <- function(ccaa = NULL, moveCAN = TRUE, ...) {

Check warning on line 95 in R/esp_get_ccaa.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/esp_get_ccaa.R,line=95,col=39,[object_name_linter] Variable and function name style should match snake_case or symbols.
params <- list(...)

# Get region id
Expand Down Expand Up @@ -194,7 +194,7 @@
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.
Loading