diff --git a/CITATION.cff b/CITATION.cff index a98fd1d8..2f6bc17d 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -159,6 +159,9 @@ references: email: jeroen@berkeley.edu orcid: https://orcid.org/0000-0002-4035-0289 year: '2024' + identifiers: + - type: url + value: https://curl.se/libcurl/ - type: software title: ggplot2 abstract: 'ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics' diff --git a/DESCRIPTION b/DESCRIPTION index 38bb02a6..ee87818d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,8 +38,9 @@ VignetteBuilder: knitr Config/Needs/check: curl Config/Needs/coverage: covr -Config/Needs/website: ragg, reactable, rnaturalearth, tidyverse, - ropenspain/rostemplate, ropensci/rnaturalearthhires, devtools, remotes +Config/Needs/website: ragg, reactable, rnaturalearth, tidyverse, devtools, + remotes, ropenspain/rostemplate, ropensci/rnaturalearthhires, + rspatial/geodata, rgeoboundaries Config/testthat/edition: 3 Config/testthat/parallel: true Copyright: © EuroGeographics for the administrative boundaries. Atlas diff --git a/R/addProviderEspTiles.R b/R/addProviderEspTiles.R index fe097245..541d393d 100644 --- a/R/addProviderEspTiles.R +++ b/R/addProviderEspTiles.R @@ -29,12 +29,24 @@ leafletprovidersESP_v <- "v1.3.3" #' #' @examples #' library(leaflet) -#' PuertadelSol <- leaflet() %>% -#' setView(lat = 40.4166, lng = -3.7038400, zoom = 18) %>% -#' addProviderEspTiles(provider = "IGNBase.Gris") %>% -#' addProviderEspTiles(provider = "RedTransporte.Carreteras") +#' leafmap <- leaflet() %>% +#' setView(lat = 40.4166, lng = -3.7038400, zoom = 6) %>% +#' addTiles(group = "Default (OSM)") %>% +#' addProviderEspTiles( +#' provider = "IDErioja.Claro", +#' group = "IDErioja Claro" +#' ) %>% +#' addProviderEspTiles( +#' provider = "RedTransporte.Carreteras", +#' group = "Carreteras" +#' ) %>% +#' addLayersControl( +#' baseGroups = c("IDErioja Claro", "Default (OSM)"), +#' overlayGroups = "Carreteras", +#' options = layersControlOptions(collapsed = FALSE) +#' ) #' -#' PuertadelSol +#' leafmap addProviderEspTiles <- function(map, provider, layerId = NULL, group = NULL, options = providerEspTileOptions()) { # A. Check providers diff --git a/codemeta.json b/codemeta.json index 1de81468..d1a71822 100644 --- a/codemeta.json +++ b/codemeta.json @@ -245,7 +245,7 @@ "applicationCategory": "cartography", "isPartOf": "https://ropenspain.es/", "keywords": ["rOpenSpain", "tiles", "r", "maps", "spatial", "rstats", "r-package", "municipalities", "Spain", "gisco", "provinces", "ign", "administrative-boundaries", "ccaa", "static-tiles", "spain", "cran", "ropenspain", "ggplot2", "gis"], - "fileSize": "2419.184KB", + "fileSize": "2417.482KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/data/esp_codelist.rda b/data/esp_codelist.rda index e3895183..f84840d6 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 4984dc91..568cc95d 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 fa207d0e..7b7d89f0 100644 Binary files a/data/leaflet.providersESP.df.rda and b/data/leaflet.providersESP.df.rda differ diff --git a/img/README-giscoR-1.png b/img/README-giscoR-1.png index 2b05dc6e..66401a9e 100644 Binary files a/img/README-giscoR-1.png and b/img/README-giscoR-1.png 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/img/README-tile-1.png b/img/README-tile-1.png index 0ff4fb59..59c556b6 100644 Binary files a/img/README-tile-1.png and b/img/README-tile-1.png differ diff --git a/man/addProviderEspTiles.Rd b/man/addProviderEspTiles.Rd index fdde8e4f..63e1d1a0 100644 --- a/man/addProviderEspTiles.Rd +++ b/man/addProviderEspTiles.Rd @@ -48,12 +48,24 @@ Include tiles of public Spanish organisms to a \code{\link[leaflet:leaflet]{leaf } \examples{ library(leaflet) -PuertadelSol <- leaflet() \%>\% - setView(lat = 40.4166, lng = -3.7038400, zoom = 18) \%>\% - addProviderEspTiles(provider = "IGNBase.Gris") \%>\% - addProviderEspTiles(provider = "RedTransporte.Carreteras") +leafmap <- leaflet() \%>\% + setView(lat = 40.4166, lng = -3.7038400, zoom = 6) \%>\% + addTiles(group = "Default (OSM)") \%>\% + addProviderEspTiles( + provider = "IDErioja.Claro", + group = "IDErioja Claro" + ) \%>\% + addProviderEspTiles( + provider = "RedTransporte.Carreteras", + group = "Carreteras" + ) \%>\% + addLayersControl( + baseGroups = c("IDErioja Claro", "Default (OSM)"), + overlayGroups = "Carreteras", + options = layersControlOptions(collapsed = FALSE) + ) -PuertadelSol +leafmap } \seealso{ \code{\link[leaflet:leaflet]{leaflet::leaflet()}}, \code{\link[leaflet:map-layers]{leaflet::addTiles()}} diff --git a/tests/testthat/test-addProviderEspTiles.R b/tests/testthat/test-addProviderEspTiles.R index 542cf603..8cbee6e2 100644 --- a/tests/testthat/test-addProviderEspTiles.R +++ b/tests/testthat/test-addProviderEspTiles.R @@ -23,7 +23,7 @@ test_that("Testing leaflet", { lng = -3.7038400, zoom = 18 ) %>% - addProviderEspTiles(provider = "IGNBase.Gris") %>% + addProviderEspTiles(provider = "IDErioja.Claro") %>% addProviderEspTiles(provider = "RedTransporte.Carreteras") ) }) diff --git a/vignettes/articles/working_imagery.Rmd b/vignettes/articles/working_imagery.Rmd index 73ce82a8..a5c65d04 100644 --- a/vignettes/articles/working_imagery.Rmd +++ b/vignettes/articles/working_imagery.Rmd @@ -102,7 +102,10 @@ can be plotted: ```{r static3} rioja <- esp_get_prov("La Rioja", epsg = 3857) -basemap <- esp_getTiles(rioja, "IGNBase.Gris", bbox_expand = 0.1, zoommin = 1) +basemap <- esp_getTiles(rioja, "IDErioja.Claro", + bbox_expand = 0.1, + zoommin = 1 +) masked <- esp_getTiles(rioja, "IGNBase.Todo", mask = TRUE, zoommin = 1) @@ -202,7 +205,7 @@ labels <- sprintf( leaflet(elementId = "SpainDemo", width = "100%", height = "60vh") %>% setView(lng = -3.684444, lat = 40.308611, zoom = 5) %>% - addProviderEspTiles("IGNBase.Gris") %>% + addProviderEspTiles("IDErioja.Claro") %>% addPolygons( data = munic_pop, fillColor = ~ pal(dens), diff --git a/vignettes/articles/x02_mapasesp.Rmd b/vignettes/articles/x02_mapasesp.Rmd index f8625e5c..9cb36049 100644 --- a/vignettes/articles/x02_mapasesp.Rmd +++ b/vignettes/articles/x02_mapasesp.Rmd @@ -114,34 +114,53 @@ reactable(galicia, ### Comparando mapSpain con otras alternativas -Comparamos ahora **mapSpain** con otro paquete que proporciona objetos `sf` de -distintos paises: +Comparamos ahora **mapSpain** con otro paquete que proporciona objetos `sf` o +`SpatVector` de distintos paises: ```{r compara} +library(sf) # manipulación de datos espaciales + # rnaturalearth library(rnaturalearth) - -esp_rnat <- ne_countries("large", country = "Spain", returnclass = "sf") +esp_rnat <- ne_countries("large", country = "Spain", returnclass = "sf") %>% + st_transform(3857) # mapSpain +esp_mapspain <- esp_get_country(epsg = 4326) %>% + st_transform(3857) + +# geodata (GADM) +library(geodata) +esp_geodata <- geodata::gadm("ES", path = tempdir(), level = 0) %>% + # Convertimos de SpatVector a objecto sf + sf::st_as_sf() %>% + st_transform(3857) -esp_mapspain <- esp_get_country(epsg = 4326) +# geoboundaries +library(rgeoboundaries) + +esp_rgeob <- gb_adm0("ESP") %>% + st_transform(3857) # Imagen Ria Ferrol tile <- esp_get_munic(munic = "Ferrol", epsg = 3857) %>% - esp_getTiles("IGNBase.Gris", bbox_expand = 0.5, zoommin = 1) + esp_getTiles("IDErioja.Claro", bbox_expand = 0.5, zoommin = 1) + # Prepara el plot library(tidyterra) -esp_all <- bind_rows(esp_rnat, esp_mapspain) +esp_all <- bind_rows(esp_rnat, esp_mapspain, esp_geodata, esp_rgeob) -esp_all$source <- c("rnaturalearth", "mapSpain") +esp_all$source <- as_factor(c( + "rnaturalearth", "mapSpain", "geodata (GADM)", + "rgeoboundaries" +)) ggplot(esp_all) + geom_spatraster_rgb(data = tile, maxcell = Inf) + - geom_sf(aes(color = source), + geom_sf(aes(color = source, linetype = source), fill = NA, show.legend = "line", linewidth = 1.2 ) + @@ -149,13 +168,16 @@ ggplot(esp_all) + crs = 4326, xlim = c(-8.384421, -8.154413), ylim = c(43.43201, 43.59545), expand = FALSE ) + - scale_color_manual(values = c("red", "black")) + + scale_color_manual(values = c("red", "black", "green", "orange")) + + scale_linetype_manual(values = c("solid", "dotted", "dashed", "twodash")) + theme_void() + labs(title = "Ría de Ferrol") ``` - **rnaturalearth**: No capta bien el contorno. - **mapSpain**: Resultados satisfactorios. +- **GADM** (libería **geodata**) y **rgeoboundaries**: Resultados muy + precisos. ### Almacenamiento @@ -444,7 +466,7 @@ ggplot() + # Usando la opción mask madrid <- esp_get_munic_siane(munic = "^Madrid$", epsg = 3857) -madrid_mask <- esp_getTiles(madrid, "IGNBase.Gris", +madrid_mask <- esp_getTiles(madrid, "IDErioja.Claro", mask = TRUE, crop = TRUE, zoommin = 2 ) @@ -473,7 +495,7 @@ leaflet(stations, width = "100%", height = "60vh" ) %>% - addProviderEspTiles("IGNBase.Gris", group = "Base") %>% + addProviderEspTiles("IDErioja.Claro", group = "Base") %>% addProviderEspTiles("MTN", group = "MTN") %>% addProviderEspTiles("RedTransporte.Ferroviario", group = "Lineas Ferroviarias" diff --git a/vignettes/basic-1.png b/vignettes/basic-1.png index 8f38a224..1b6e4c61 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..302c600f 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..2a04176e 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..42178a6c 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..ffdf9709 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..02c3b161 100644 Binary files a/vignettes/thematic-1.png and b/vignettes/thematic-1.png differ