diff --git a/DESCRIPTION b/DESCRIPTION index ed2a57c2..38bb02a6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -39,7 +39,7 @@ VignetteBuilder: Config/Needs/check: curl Config/Needs/coverage: covr Config/Needs/website: ragg, reactable, rnaturalearth, tidyverse, - ropenspain/rostemplate, ropensci/rnaturalearthhires, devtools + ropenspain/rostemplate, ropensci/rnaturalearthhires, devtools, remotes 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 e5128bef..fe097245 100644 --- a/R/addProviderEspTiles.R +++ b/R/addProviderEspTiles.R @@ -6,8 +6,7 @@ leafletprovidersESP_v <- "v1.3.3" #' map #' #' @description -#' Include tiles of public Spanish organisms to a -#' [leaflet::leaflet()] map. +#' Include tiles of public Spanish organisms to a [leaflet::leaflet()] map. #' #' @family imagery utilities #' @seealso [leaflet::leaflet()], [leaflet::addTiles()] @@ -21,41 +20,23 @@ leafletprovidersESP_v <- "v1.3.3" #' #' @return A modified [leaflet::leaflet()] `map` object. #' -#' -#' #' @export #' -#' @param map A map widget created from [leaflet::leaflet()]. -#' @param group The name of the group the newly created layers should belong to -#' Human-friendly group names are permitted–they need not be short, -#' identifier-style names. Any number of layers and even different types of -#' layers (e.g. markers and polygons) can share the same group name. See -#' [leaflet::addTiles()]. #' @param provider Name of the provider, see [esp_tiles_providers] for #' values available. -#' @param ... Arguments passed on to [leaflet::providerTileOptions()]. +#' @inheritParams leaflet::addProviderTiles #' @inheritParams leaflet::addTiles #' #' @examples #' library(leaflet) -#' PuertadelSol <- -#' leaflet() %>% -#' setView( -#' lat = 40.4166, -#' lng = -3.7038400, -#' zoom = 18 -#' ) %>% +#' PuertadelSol <- leaflet() %>% +#' setView(lat = 40.4166, lng = -3.7038400, zoom = 18) %>% #' addProviderEspTiles(provider = "IGNBase.Gris") %>% #' addProviderEspTiles(provider = "RedTransporte.Carreteras") #' #' PuertadelSol -addProviderEspTiles <- function(map, provider, layerId = NULL, - group = NULL, +addProviderEspTiles <- function(map, provider, layerId = NULL, group = NULL, options = providerEspTileOptions()) { - if (!requireNamespace("leaflet", quietly = TRUE)) { - stop("leaflet package required for using this function") - } - # A. Check providers prov_list <- mapSpain::esp_tiles_providers @@ -64,8 +45,7 @@ addProviderEspTiles <- function(map, provider, layerId = NULL, if (!provider %in% allprovs) { stop( - "No match for provider = '", - provider, + "No match for provider = '", provider, "' found.\n\nCheck available providers in mapSpain::esp_tiles_providers." ) } @@ -176,18 +156,13 @@ addProviderEspTiles <- function(map, provider, layerId = NULL, #' @name providerEspTileOptions #' #' @details -#' [providerEspTileOptions()] is a wrapper of -#' [leaflet::providerTileOptions()]. -#' +#' [providerEspTileOptions()] is a wrapper of [leaflet::providerTileOptions()]. #' +#' @param ... Arguments passed on to [leaflet::providerTileOptions()]. #' @seealso [leaflet::providerTileOptions()], [leaflet::tileOptions()] #' #' @export providerEspTileOptions <- function(...) { - if (!requireNamespace("leaflet", quietly = TRUE)) { - stop("leaflet package required for using this function") - } - ops <- leaflet::providerTileOptions(...) return(ops) } diff --git a/R/data.R b/R/data.R index 88d47802..b148f7e6 100644 --- a/R/data.R +++ b/R/data.R @@ -1,4 +1,4 @@ -#' Spanish Code Translation Data Frame +#' Database with codes and names of spanish regions #' #' @family datasets #' @family political @@ -9,21 +9,21 @@ #' @docType data #' #' @description -#' A data frame used internally for translating codes and names of the -#' different subdivisions of Spain. The data frame provides the hierarchy of -#' the subdivisions including NUTS1 level, Autonomous Communities -#' (equivalent to NUTS2), Provinces and NUTS3 level. See **Note**. +#' A `data.frame` object used internally for translating codes and names of the +#' different subdivisions of Spain. The `data.frame` provides the hierarchy of +#' the subdivisions including NUTS1 level, autonomous communities (equivalent +#' to NUTS2), provinces and NUTS3 level. See **Note**. #' #' @source -#' * **INE**: Instituto Nacional de Estadistica: -#' * **Eurostat (NUTS)**: -#' * **ISO**: -#' * **CLDR**: +#' - **INE**: Instituto Nacional de Estadistica: +#' - **Eurostat (NUTS)**: +#' - **ISO**: +#' - **CLDR**: #' #' @encoding UTF-8 #' #' @format -#' A data frame with `r nrow(mapSpain::esp_codelist)` rows +#' A [`data.frame`][base::data.frame] with `r nrow(mapSpain::esp_codelist)` rows #' codes and columns: #' #' \describe{ @@ -83,11 +83,11 @@ #' Although NUTS2 matches the first subdivision level of Spain #' (CCAA - Autonomous Communities), it should be noted that NUTS3 does not #' match the second subdivision level of Spain (Provinces). NUTS3 provides a -#' dedicated code for major islands whereas the Provinces doesn't. +#' dedicated code for major islands whereas the provinces doesn't. #' #' Ceuta and Melilla has an specific status (Autonomous Cities) but are -#' considered as communities with a single province (as Madrid, Asturias -#' or Murcia) on this dataset. +#' considered as autonomous communities with a single province (as Madrid, +#' Asturias or Murcia) on this database. #' #' @examples #' @@ -95,7 +95,7 @@ NULL -#' All NUTS `POLYGON` object of Spain +#' [`sf`][sf::st_sf] object with all the NUTS levels of Spain (2016) #' #' @family datasets #' @family nuts @@ -122,7 +122,7 @@ NULL #' \item{LEVL_CODE}{NUTS level code (0,1,2,3)} #' \item{NUTS_ID}{NUTS identifier} #' \item{URBN_TYPE}{Urban Type, see Details} -#' \item{CNTR_CODE}{Eurostat Country code \code{ES}} +#' \item{CNTR_CODE}{Eurostat Country code `ES`} #' \item{NAME_LATN}{NUTS name on Latin characters} #' \item{NUTS_NAME}{NUTS name on local alphabet} #' \item{MOUNT_TYPE}{Mount Type, see Details} @@ -159,8 +159,7 @@ NULL #' NULL -#' All Municipalities `POLYGON` object of Spain (2019) -#' +#' [`sf`][sf::st_sf] object with all the municipalities of Spain (2019) #' @family datasets #' @family municipalities #' @@ -187,7 +186,7 @@ NULL #' #' @seealso [esp_get_munic()]. #' @format -#' A [`sf`][sf::st_sf] object (resolution: 1:1million, EPSG:4258) object with +#' A [`sf`][sf::st_sf] object (resolution: 1:1 million, EPSG:4258) object with #' `r prettyNum(nrow(mapSpain::esp_munic.sf), big.mark=",")` rows and columns: #' \describe{ #' \item{codauto}{INE code of the autonomous community.} @@ -197,14 +196,15 @@ NULL #' \item{cmun}{INE code of the municipality.} #' \item{name}{Name of the municipality.} #' \item{LAU_CODE}{LAU Code (GISCO) of the municipality. This is a -#' combination of **cpro** and **cmun**, aligned with INE coding scheme.} +#' combination of **cpro** and **cmun** fields, aligned with INE coding +#' scheme.} #' \item{geometry}{geometry field.} #' } #' @example inst/examples/esp_munic_sf.R NULL -#' @title Population by municipality (2019) +#' Database with the population of Spain by municipality (2019) #' #' @family datasets #' @@ -213,7 +213,7 @@ NULL #' @docType data #' #' @format -#' An example data frame with +#' An example `data.frame` object with #' `r prettyNum(nrow(mapSpain::pobmun19), big.mark=",")` rows containing the #' population data by municipality in Spain (2019). #' @@ -234,7 +234,7 @@ NULL NULL -#' @title Public WMS and WMTS of Spain +#' (Superseded) Database of public WMS and WMTS of Spain #' #' @keywords internal #' @@ -243,10 +243,10 @@ NULL #' @description #' `r lifecycle::badge('superseded')` #' -#' This data frame is not longer in use by \CRANpkg{mapSpain}. See +#' This `data.frame` is not longer in use by \CRANpkg{mapSpain}. See #' [esp_tiles_providers] instead. #' -#' A data frame containing information of different public WMS and WMTS +#' A `data.frame` containing information of different public WMS and WMTS #' providers of Spain #' #' @@ -259,7 +259,7 @@ NULL #' @encoding UTF-8 #' #' @format -#' A data frame object with a list of the required parameters for calling +#' A `data.frame` object with a list of the required parameters for calling #' the service: #' \describe{ #' \item{provider}{Provider name}. @@ -271,7 +271,7 @@ NULL #' data("leaflet.providersESP.df") NULL -#' @title List with information of Public WMS and WMTS of Spain +#' Database of public WMS and WMTS of Spain #' #' @family datasets #' @family imagery utilities @@ -279,9 +279,9 @@ NULL #' @name esp_tiles_providers #' #' @description -#' A named list of length `r length(esp_tiles_providers)` containing -#' the parameters of the url information of different public WMS and WMTS -#' providers of Spain. +#' A named [`list`][base::list] of length `r length(esp_tiles_providers)` +#' containing the parameters of the url information of different public WMS and +#' WMTSproviders of Spain. #' #' Implementation of javascript plugin #' [leaflet-providersESP](https://dieghernan.github.io/leaflet-providersESP/) @@ -296,7 +296,7 @@ NULL #' @encoding UTF-8 #' #' @format -#' A named list of the providers available with the following structure: +#' A named `list` of the providers available with the following structure: #' - Each item of the list is named with the provider alias. #' - Each element of the list contains two nested named lists: #' - `static` with the parameters to get static tiles plus an additional item diff --git a/R/esp_cache.R b/R/esp_cache.R index 847e9f3b..7e0d8d6f 100644 --- a/R/esp_cache.R +++ b/R/esp_cache.R @@ -3,7 +3,9 @@ #' @family cache utilities #' @seealso [rappdirs::user_config_dir()] #' -#' @return An (invisible) character with the path to your `cache_dir`. +#' @return +#' An (invisible) character with the path to your `cache_dir`. +#' #' @description #' This function will store your `cache_dir` path on your local machine and #' would load it for future sessions. Type `Sys.getenv("MAPSPAIN_CACHE_DIR")` to @@ -11,24 +13,23 @@ #' #' Alternatively, you can store the `cache_dir` manually with the following #' options: -#' * Run `Sys.setenv(MAPSPAIN_CACHE_DIR = "cache_dir")`. You would need to -#' run this command on each session (Similar to `install = FALSE`). -#' * Set `options(mapSpain_cache_dir = "cache_dir")`. Similar to the previous -#' option. This is **not recommended any more**, and it is provided for -#' backwards compatibility purposes. -#' * Write this line on your .Renviron file: -#' `MAPSPAIN_CACHE_DIR = "value_for_cache_dir"` (same behavior than -#' `install = TRUE`). This would store your `cache_dir` permanently. +#' - Run `Sys.setenv(MAPSPAIN_CACHE_DIR = "cache_dir")`. You would need to +#' run this command on each session (Similar to `install = FALSE`). +#' - Set `options(mapSpain_cache_dir = "cache_dir")`. Similar to the previous +#' option. This is **not recommended any more**, and it is provided for +#' backwards compatibility purposes. +#' - Write this line on your .Renviron file: +#' `MAPSPAIN_CACHE_DIR = "value_for_cache_dir"` (same behavior than +#' `install = TRUE`). This would store your `cache_dir` permanently. #' #' @inheritParams esp_get_nuts #' @param cache_dir A path to a cache directory. On missing value the function #' would store the cached files on a temporary dir (See [base::tempdir()]). -#' @param install if `TRUE`, will install the key in your local machine for -#' use in future sessions. Defaults to `FALSE.` If `cache_dir` is `FALSE` -#' this parameter is set to `FALSE` automatically. -#' @param overwrite If this is set to `TRUE`, it will overwrite an existing -#' `MAPSPAIN_CACHE_DIR` that you already have in local machine. -#' +#' @param install Logical. If `TRUE`, will install the key in your local +#' machine for use in future sessions. Defaults to `FALSE.` If `cache_dir` +#' is `FALSE` this parameter is set to `FALSE` automatically. +#' @param overwrite Logical. If this is set to `TRUE`, it will overwrite an +#' existing `MAPSPAIN_CACHE_DIR` that you already have in local machine. #' #' @examples #' @@ -39,9 +40,7 @@ #' #' Sys.getenv("MAPSPAIN_CACHE_DIR") #' @export -esp_set_cache_dir <- function(cache_dir, - overwrite = FALSE, - install = FALSE, +esp_set_cache_dir <- function(cache_dir, overwrite = FALSE, install = FALSE, verbose = TRUE) { # Default if not provided if (missing(cache_dir) || cache_dir == "") { @@ -205,10 +204,10 @@ esp_hlp_cachedir <- function(cache_dir = NULL) { #' @description #' #' Helper function to detect the current cache folder. See -#' [esp_set_cache_dir()] +#' [esp_set_cache_dir()]. #' #' -#' @param x Ignored +#' @param x Ignored. #' #' @return A character with the path to your `cache_dir`. #' diff --git a/R/esp_cache_clear.R b/R/esp_cache_clear.R index 258940ae..df361253 100644 --- a/R/esp_cache_clear.R +++ b/R/esp_cache_clear.R @@ -8,16 +8,16 @@ #' **Use this function with caution**. This function would clear your cached #' data and configuration, specifically: #' -#' * Deletes the \CRANpkg{mapSpain} config directory +#' - Deletes the \CRANpkg{mapSpain} config directory #' (`rappdirs::user_config_dir("mapSpain", "R")`). -#' * Deletes the `cache_dir` directory. -#' * Deletes the values on stored on `Sys.getenv("MAPSPAIN_CACHE_DIR")` and +#' - Deletes the `cache_dir` directory. +#' - Deletes the values on stored on `Sys.getenv("MAPSPAIN_CACHE_DIR")` and #' `options(mapSpain_cache_dir)`. #' -#' @param config if `TRUE`, will delete the configuration folder of +#' @param config Logical. If `TRUE`, will delete the configuration folder of #' \CRANpkg{mapSpain}. -#' @param cached_data If this is set to `TRUE`, it will delete your -#' `cache_dir` and all its content. +#' @param cached_data Logical. If `TRUE`, it will delete your `cache_dir` and +#' all its content. #' @inheritParams esp_set_cache_dir #' #' @details @@ -33,8 +33,7 @@ #' #' Sys.getenv("MAPSPAIN_CACHE_DIR") #' @export -esp_clear_cache <- function(config = FALSE, - cached_data = TRUE, +esp_clear_cache <- function(config = FALSE, cached_data = TRUE, verbose = FALSE) { config_dir <- rappdirs::user_config_dir("mapSpain", "R") data_dir <- esp_hlp_detect_cache_dir() diff --git a/R/esp_dict.R b/R/esp_dict.R index ec2fdc8a..96c0fdf8 100644 --- a/R/esp_dict.R +++ b/R/esp_dict.R @@ -1,5 +1,6 @@ #' Convert and translate subdivision names #' +#' @description #' Converts long subdivision names into different coding schemes and languages. #' #' @family dictionary @@ -15,8 +16,8 @@ #' #' @param sourcevar Vector which contains the subdivision names to be converted. #' -#' @param origin,destination One of `"text"`, `"nuts"`, `"iso2"`, -#' `"codauto"` and `"cpro"`. +#' @param origin,destination One of `"text"`, `"nuts"`, `"iso2"`, `"codauto"` +#' and `"cpro"`. #' #' @details #' If no match is found for any value, the function displays a warning and @@ -58,8 +59,7 @@ #' esp_dict_region_code(valsmix, destination = "iso2") #' } #' -esp_dict_region_code <- function(sourcevar, - origin = "text", +esp_dict_region_code <- function(sourcevar, origin = "text", destination = "text") { initsourcevar <- sourcevar @@ -193,18 +193,19 @@ esp_dict_region_code <- function(sourcevar, #' #' @name esp_dict_translate #' -#' @return [esp_dict_translate()] returns a character vector or a named -#' list with each of the possible names of each `sourcevar` on the required -#' language `lang`. +#' @return +#' [esp_dict_translate()] returns a `character` vector or a named `list` with +#' each of the possible names of each `sourcevar` on the required language +#' `lang`. #' #' @export #' #' @param lang Language of translation. Available languages are: -#' * `"es"`: Spanish -#' * `"en"`: English -#' * `"ca"`: Catalan -#' * `"ga"`: Galician -#' * `"eu"`: Basque +#' - `"es"`: Spanish +#' - `"en"`: English +#' - `"ca"`: Catalan +#' - `"ga"`: Galician +#' - `"eu"`: Basque #' #' @param all Logical. Should the function return all names or not? #' On `FALSE` it returns a character vector. See **Value**. diff --git a/R/esp_getTiles.R b/R/esp_getTiles.R index 71cc8e26..da5c0ae4 100644 --- a/R/esp_getTiles.R +++ b/R/esp_getTiles.R @@ -154,46 +154,19 @@ #' autoplot(cartodb, maxcell = Inf) + #' geom_sf(data = segovia, fill = NA, color = "black", linewidth = 1) #' } -esp_getTiles <- function(x, - type = "IDErioja", - zoom = NULL, - zoommin = 0, - crop = TRUE, - res = 512, - bbox_expand = 0.05, - transparent = TRUE, - mask = FALSE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - options = NULL) { - # nocov start - - if (!requireNamespace("slippymath", quietly = TRUE)) { - stop("slippymath package required for using this function") - } - if (!requireNamespace("terra", quietly = TRUE)) { - stop("terra package required for using this function") - } - if (!requireNamespace("png", quietly = TRUE)) { - stop("png package required for using this function") - } - # nocov end +esp_getTiles <- function(x, type = "IDErioja", zoom = NULL, zoommin = 0, + crop = TRUE, res = 512, bbox_expand = 0.05, + transparent = TRUE, mask = FALSE, update_cache = FALSE, + cache_dir = NULL, verbose = FALSE, options = NULL) { # Only sf and sfc objects allowed if (!inherits(x, "sf") && !inherits(x, "sfc")) { - stop( - "Only sf and sfc ", - "objects allowed" - ) + stop("Only sf and sfc objects allowed") } # If sfc convert to sf if (inherits(x, "sfc")) { - x <- sf::st_as_sf( - data.frame(x = 1), - x - ) + x <- sf::st_as_sf(data.frame(x = 1), x) } @@ -288,8 +261,6 @@ esp_getTiles <- function(x, options <- options[ig] } - - url_pieces <- modifyList(url_pieces, options) # Create new cache dir @@ -333,39 +304,22 @@ esp_getTiles <- function(x, newbbox <- esp_hlp_get_bbox(x, bbox_expand, typeprov) if (typeprov == "WMS") { - rout <- - getwms( - newbbox, - url_pieces, - update_cache, - cache_dir, - verbose, - res, - transparent - ) + rout <- getwms( + newbbox, url_pieces, update_cache, cache_dir, verbose, + res, transparent + ) } else { - rout <- - getwmts( - newbbox, - type, - url_pieces, - update_cache, - cache_dir, - verbose, - zoom, - zoommin, - transparent, - extra_opts - ) + rout <- getwmts( + newbbox, type, url_pieces, update_cache, cache_dir, verbose, + zoom, zoommin, transparent, extra_opts + ) } # Regenerate # Display attributions if (verbose && !is.null(attr)) { - message( - "\nData and map tiles sources:\n", attr - ) + message("\nData and map tiles sources:\n", attr) } x <- xinit @@ -375,10 +329,7 @@ esp_getTiles <- function(x, if (!sf::st_crs(x) == sf::st_crs(rout)) { # Sometimes it gets an error - rout_end <- try(terra::project( - rout, - terra::crs(x_terra) - ), silent = TRUE) + rout_end <- try(terra::project(rout, terra::crs(x_terra)), silent = TRUE) if (inherits(rout_end, "try-error")) { if (verbose) message("Tile not reprojected.") @@ -388,11 +339,7 @@ esp_getTiles <- function(x, } } - rout <- terra::clamp(rout, - lower = 0, - upper = 255, - values = TRUE - ) + rout <- terra::clamp(rout, lower = 0, upper = 255, values = TRUE) # crop management diff --git a/R/esp_get_can_box.R b/R/esp_get_can_box.R index bc3154a0..a7e5402b 100644 --- a/R/esp_get_can_box.R +++ b/R/esp_get_can_box.R @@ -6,7 +6,7 @@ #' lines and polygons to be used when the Canary Islands are displayed #' as an inset. #' -#' * [esp_get_can_box()] is used to draw lines around the displaced Canary +#' - [esp_get_can_box()] is used to draw lines around the displaced Canary #' Islands. #' #' @family political @@ -16,8 +16,8 @@ #' #' @name esp_get_can_box #' -#' @return A [`sf`][sf::st_sf] polygon or line depending of `style` parameter. -#' +#' @return A [`sf`][sf::st_sf] `POLYGON` or `LINESTRING` depending of `style` +#' parameter. #' #' @export #' @@ -105,9 +105,7 @@ #' panel.grid = element_blank() #' ) #' } -esp_get_can_box <- function(style = "right", - moveCAN = TRUE, - epsg = "4258") { +esp_get_can_box <- function(style = "right", moveCAN = TRUE, epsg = "4258") { # checks if (!style %in% c("left", "right", "box", "poly")) { stop("style should be one of 'right','left','box'") @@ -173,8 +171,8 @@ esp_get_can_box <- function(style = "right", #' #' #' @description -#' * [esp_get_can_provinces()] is used to draw a separator line between the two -#' provinces of the Canary Islands. +#' - [esp_get_can_provinces()] is used to draw a separator line between the two +#' provinces of the Canary Islands. #' #' See also [esp_move_can()] to displace stand-alone objects on the Canary #' Islands. @@ -186,8 +184,7 @@ esp_get_can_box <- function(style = "right", #' `se89_mult_admin_provcan_l.shp` file. #' #' @export -esp_get_can_provinces <- function(moveCAN = TRUE, - epsg = "4258") { +esp_get_can_provinces <- function(moveCAN = TRUE, epsg = "4258") { epsg <- as.character(epsg) if (!epsg %in% c("4258", "4326", "3035", "3857")) { diff --git a/R/esp_get_capimun.R b/R/esp_get_capimun.R index 1085689e..2951ac60 100644 --- a/R/esp_get_capimun.R +++ b/R/esp_get_capimun.R @@ -1,7 +1,7 @@ -#' Get [`sf`][sf::st_sf] points of the municipalities of Spain +#' Get [`sf`][sf::st_sf] `POINT` of the municipalities of Spain #' #' @description -#' Get a [`sf`][sf::st_sf] point with the location of the political powers for +#' Get a [`sf`][sf::st_sf] `POINT` with the location of the political powers for #' each municipality (possibly the center of the municipality). #' #' Note that this differs of the centroid of the boundaries of the @@ -10,7 +10,7 @@ #' @family political #' @family municipalities #' -#' @return A [`sf`][sf::st_sf] point object. +#' @return A [`sf`][sf::st_sf] `POINT` object. #' #' @source IGN data via a custom CDN (see #' ). @@ -36,8 +36,8 @@ #' 2 or 3), ISO codes (corresponding to level 2 or 3) or `cpro`. See #' [esp_codelist] #' -#' When calling a superior level (Province, Autonomous Community or NUTS1) , -#' all the municipalities of that level would be added. +#' When calling a higher level (province, CCAA or NUTS1), all the municipalities +#' of that level would be added. #' #' @export #' @@ -84,16 +84,10 @@ #' theme_void() + #' labs(title = "Centroid vs. capimun") #' } -esp_get_capimun <- function(year = Sys.Date(), - epsg = "4258", - cache = TRUE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - region = NULL, - munic = NULL, - moveCAN = TRUE, - rawcols = FALSE) { +esp_get_capimun <- function(year = Sys.Date(), epsg = "4258", cache = TRUE, + update_cache = FALSE, cache_dir = NULL, + verbose = FALSE, region = NULL, munic = NULL, + moveCAN = TRUE, rawcols = FALSE) { init_epsg <- as.character(epsg) year <- as.character(year) @@ -122,10 +116,10 @@ esp_get_capimun <- function(year = Sys.Date(), ) cod <- unique( - mapSpain::esp_codelist[, c( - "codauto", - "ine.ccaa.name", "cpro", "ine.prov.name" - )] + mapSpain::esp_codelist[ + , + c("codauto", "ine.ccaa.name", "cpro", "ine.prov.name") + ] ) df2 <- merge(df, cod, by = "cpro", all.x = TRUE, no.dups = TRUE) @@ -147,10 +141,7 @@ esp_get_capimun <- function(year = Sys.Date(), } if (nrow(data_sf) == 0) { - stop( - "The combination of region and/or munic does ", - "not return any result" - ) + stop("The combination of region and/or munic does not return any result") } # Move CAN diff --git a/R/esp_get_ccaa.R b/R/esp_get_ccaa.R index 53cb3130..dcc505ba 100644 --- a/R/esp_get_ccaa.R +++ b/R/esp_get_ccaa.R @@ -1,12 +1,12 @@ -#' Get Autonomous Communities of Spain as [`sf`][sf::st_sf] polygons and points +#' Get Autonomous Communities of Spain as [`sf`][sf::st_sf] `POLYGON` or `POINT` #' #' @description #' Returns #' [Autonomous Communities of #' Spain](https://en.wikipedia.org/wiki/Autonomous_communities_of_Spain) as -#' polygons and points at a specified scale. +#' `sf` `POLYGON` or `POINT` at a specified scale. #' -#' * [esp_get_ccaa()] uses GISCO (Eurostat) as source. Please use +#' - [esp_get_ccaa()] uses GISCO (Eurostat) as source. Please use #' [giscoR::gisco_attributions()] #' #' @family political @@ -147,7 +147,7 @@ esp_get_ccaa <- function(ccaa = NULL, moveCAN = TRUE, ...) { #' @name esp_get_ccaa_siane #' #' @description -#' * [esp_get_ccaa_siane()] uses CartoBase ANE as source, provided by +#' - [esp_get_ccaa_siane()] uses CartoBase ANE as source, provided by #' Instituto Geografico Nacional (IGN), . #' Years available are 2005 up to today. #' @@ -158,13 +158,13 @@ esp_get_ccaa <- function(ccaa = NULL, moveCAN = TRUE, ...) { #' @export #' #' @param year Release year. See [esp_get_nuts()] for [esp_get_ccaa()] and -#' **Details** for [esp_get_ccaa_siane()] +#' **Details** for [esp_get_ccaa_siane()]. #' -#' @param resolution Resolution of the polygon. Values available are +#' @param resolution Resolution of the `POLYGON`. Values available are #' `3`, `6.5` or `10`. #' #' @param rawcols Logical. Setting this to `TRUE` would add the raw columns of -#' the dataset provided by IGN. +#' the resulting object as provided by IGN. #' #' @inheritParams esp_get_nuts #' @@ -172,16 +172,10 @@ esp_get_ccaa <- function(ccaa = NULL, moveCAN = TRUE, ...) { #' On [esp_get_ccaa_siane()], `year` could be passed as a single year (`YYYY` #' format, as end of year) or as a specific date (`YYYY-MM-DD` format). #' Historical information starts as of 2005. - -esp_get_ccaa_siane <- function(ccaa = NULL, - year = Sys.Date(), - epsg = "4258", - cache = TRUE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - resolution = "3", - moveCAN = TRUE, +esp_get_ccaa_siane <- function(ccaa = NULL, year = Sys.Date(), epsg = "4258", + cache = TRUE, update_cache = FALSE, + cache_dir = NULL, verbose = FALSE, + resolution = "3", moveCAN = TRUE, rawcols = FALSE) { init_epsg <- as.character(epsg) year <- as.character(year) diff --git a/R/esp_get_comarca.R b/R/esp_get_comarca.R index 8d335ce0..fbbeab13 100644 --- a/R/esp_get_comarca.R +++ b/R/esp_get_comarca.R @@ -1,7 +1,7 @@ -#' Get 'comarcas' of Spain as [`sf`][sf::st_sf] polygons +#' Get 'comarcas' of Spain as [`sf`][sf::st_sf] `POLYGON` #' #' @description -#' Returns 'comarcas' of Spain as polygons,as provided by the +#' Returns 'comarcas' of Spain as `sf` `POLYGON` objects, as provided by the #' **INE** (Instituto Nacional de Estadistica). #' #' @source INE: PC_Axis files. @@ -11,10 +11,10 @@ #' @family political #' #' @param region A vector of names and/or codes for provinces or `NULL` to get -#' all the comarcas., See **Details**. +#' all the comarcas. See **Details**. #' #' @param comarca A name or [`regex`][base::grep()] expression with the names of -#' the required comarcas. `NULL` would not produce any filtering. +#' the required comarcas. `NULL` would return all the possible comarcas. #' #' @inheritParams esp_get_munic #' @@ -35,7 +35,7 @@ #' (levels 1, 2 or 3), ISO codes (corresponding to level 2 or 3) or #' "cpro" (see [esp_codelist]). #' -#' When calling a superior level (Province, Autonomous Community or NUTS1) , +#' When calling a higher level (Province, Autonomous Community or NUTS1), #' all the comarcas of that level would be added. #' #' ## Legal Notice @@ -77,13 +77,9 @@ #' labs(fill = "CCAA") #' } #' -esp_get_comarca <- function(region = NULL, - comarca = NULL, - moveCAN = TRUE, - epsg = "4258", - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE) { +esp_get_comarca <- function(region = NULL, comarca = NULL, moveCAN = TRUE, + epsg = "4258", update_cache = FALSE, + cache_dir = NULL, verbose = FALSE) { init_epsg <- as.character(epsg) if (!init_epsg %in% c("4326", "4258", "3035", "3857")) { diff --git a/R/esp_get_country.R b/R/esp_get_country.R index d57573b9..b55c296b 100644 --- a/R/esp_get_country.R +++ b/R/esp_get_country.R @@ -1,12 +1,12 @@ -#' Get the borders of Spain as a [`sf`][sf::st_sf] polygon +#' Get [`sf`][sf::st_sf] `POLYGON` representing Spain #' #' @description -#' Returns the boundaries of Spain as a single [`sf`][sf::st_sf] polygon at a +#' Returns the boundaries of Spain as a single [`sf`][sf::st_sf] `POLYGON` at a #' specified scale. #' #' @family political #' -#' @return A [`sf`][sf::st_sf] polygon object. +#' @return A [`sf`][sf::st_sf] `POLYGON` object. #' #' #' @export diff --git a/R/esp_get_grid_BDN.R b/R/esp_get_grid_BDN.R index 767784a0..fbdb1234 100644 --- a/R/esp_get_grid_BDN.R +++ b/R/esp_get_grid_BDN.R @@ -1,20 +1,21 @@ -#' Get [`sf`][sf::st_sf] polygons with the national geographic grids from BDN +#' Get [`sf`][sf::st_sf] `POLYGON` with the national geographic grids from BDN #' #' @description -#' Loads a [`sf`][sf::st_sf] polygon with the geographic grids of Spain as +#' Loads a [`sf`][sf::st_sf] `POLYGON` with the geographic grids of Spain as #' provided on the Banco de Datos de la Naturaleza (Nature Data Bank), by the #' Ministry of Environment (MITECO): -#' * [esp_get_grid_BDN()] extracts country-wide grids with resolutions +#' - [esp_get_grid_BDN()] extracts country-wide grids with resolutions #' 5x5 or 10x10 kms. -#' * [esp_get_grid_BDN_ccaa()] extracts grids by Autonomous Community with +#' - [esp_get_grid_BDN_ccaa()] extracts grids by Autonomous Community with #' resolution 1x1 km. #' #' @family grids #' -#' @return A [`sf`][sf::st_sf] polygon +#' @return A [`sf`][sf::st_sf] `POLYGON`. #' #' -#' @source BDN data via a custom CDN (see +#' @source +#' BDN data via a custom CDN (see #' ). #' #' See original metadata and source on @@ -40,10 +41,8 @@ #' theme_light() + #' labs(title = "BDN Grid for Spain") #' } -esp_get_grid_BDN <- function(resolution = 10, - type = "main", - update_cache = FALSE, - cache_dir = NULL, +esp_get_grid_BDN <- function(resolution = 10, type = "main", + update_cache = FALSE, cache_dir = NULL, verbose = FALSE) { # Check grid res <- as.numeric(resolution) @@ -56,7 +55,6 @@ esp_get_grid_BDN <- function(resolution = 10, stop("type should be one of 'main', 'canary'") } - # Url api_entry <- paste0( "https://github.com/rOpenSpain/mapSpain/raw/", @@ -93,15 +91,12 @@ esp_get_grid_BDN <- function(resolution = 10, #' See **Details** on [esp_get_ccaa()]. #' @seealso [esp_get_ccaa()] -esp_get_grid_BDN_ccaa <- function(ccaa, - update_cache = FALSE, - cache_dir = NULL, +esp_get_grid_BDN_ccaa <- function(ccaa, update_cache = FALSE, cache_dir = NULL, verbose = FALSE) { # Get region id ccaa <- ccaa[!is.na(ccaa)] - region <- ccaa if (is.null(region)) { stop("ccaa can't be null") diff --git a/R/esp_get_grid_EEA.R b/R/esp_get_grid_EEA.R index d2ac4bcd..abdccfd9 100644 --- a/R/esp_get_grid_EEA.R +++ b/R/esp_get_grid_EEA.R @@ -1,12 +1,12 @@ -#' Get [`sf`][sf::st_sf] polygons of the national geographic grids from EEA +#' Get [`sf`][sf::st_sf] `POLYGON` of the national geographic grids from EEA #' #' @description -#' Loads a [`sf`][sf::st_sf] polygon with the geographic grids of Spain as +#' Loads a [`sf`][sf::st_sf] `POLYGON` with the geographic grids of Spain as #' provided by the European Environment Agency (EEA). #' #' @family grids #' -#' @return A [`sf`][sf::st_sf] polygon +#' @return A [`sf`][sf::st_sf] `POLYGON`. #' #' #' @source @@ -35,10 +35,8 @@ #' theme_light() + #' labs(title = "EEA Grid for Spain") #' } -esp_get_grid_EEA <- function(resolution = 100, - type = "main", - update_cache = FALSE, - cache_dir = NULL, +esp_get_grid_EEA <- function(resolution = 100, type = "main", + update_cache = FALSE, cache_dir = NULL, verbose = FALSE) { # Check grid res <- as.numeric(resolution) diff --git a/R/esp_get_grid_ESDAC.R b/R/esp_get_grid_ESDAC.R index 949ee168..ce293225 100644 --- a/R/esp_get_grid_ESDAC.R +++ b/R/esp_get_grid_ESDAC.R @@ -1,12 +1,12 @@ -#' Get [`sf`][sf::st_sf] polygons of the national geographic grids from ESDAC +#' Get [`sf`][sf::st_sf] `POLYGON` of the national geographic grids from ESDAC #' #' @description -#' Loads a [`sf`][sf::st_sf] polygon with the geographic grids of Spain as +#' Loads a [`sf`][sf::st_sf] `POLYGON` with the geographic grids of Spain as #' provided by the European Soil Data Centre (ESDAC). #' #' @family grids #' -#' @return A [`sf`][sf::st_sf] polygon +#' @return A [`sf`][sf::st_sf] `POLYGON`. #' #' #' @source @@ -41,10 +41,8 @@ #' labs(title = "ESDAC Grid for Spain") #' } #' -esp_get_grid_ESDAC <- function(resolution = 10, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE) { +esp_get_grid_ESDAC <- function(resolution = 10, update_cache = FALSE, + cache_dir = NULL, verbose = FALSE) { # Check grid res <- as.numeric(resolution) diff --git a/R/esp_get_grid_MTN.R b/R/esp_get_grid_MTN.R index 19fb0ea4..480734c6 100644 --- a/R/esp_get_grid_MTN.R +++ b/R/esp_get_grid_MTN.R @@ -1,11 +1,11 @@ -#' Get [`sf`][sf::st_sf] polygons of the national geographic grids from IGN +#' Get [`sf`][sf::st_sf] `POLYGON` of the national geographic grids from IGN #' #' @description -#' Loads a [`sf`][sf::st_sf] polygon with the geographic grids of Spain. +#' Loads a [`sf`][sf::st_sf] `POLYGON` with the geographic grids of Spain. #' #' @family grids #' -#' @return A [`sf`][sf::st_sf] polygon +#' @return A [`sf`][sf::st_sf] `POLYGON`. #' #' #' @source IGN data via a custom CDN (see @@ -111,8 +111,7 @@ #' labs(title = "MTN50 Grid for Spain") #' } esp_get_grid_MTN <- function(grid = "MTN25_ETRS89_Peninsula_Baleares_Canarias", - update_cache = FALSE, - cache_dir = NULL, + update_cache = FALSE, cache_dir = NULL, verbose = FALSE) { # Check grid init_grid <- grid diff --git a/R/esp_get_gridmap.R b/R/esp_get_gridmap.R index 9b5fd1b8..80b5a809 100644 --- a/R/esp_get_gridmap.R +++ b/R/esp_get_gridmap.R @@ -1,4 +1,4 @@ -#' Get a [`sf`][sf::st_sf] hexbin or squared polygon of Spain +#' Get a [`sf`][sf::st_sf] hexbin or squared `POLYGON` of Spain #' #' @description #' Loads a hexbin map ([`sf`][sf::st_sf] object) or a map of squares with the @@ -9,7 +9,7 @@ #' #' @family political #' -#' @return A [`sf`][sf::st_sf] POLYGON object. +#' @return A [`sf`][sf::st_sf] `POLYGON` object. #' #' #' @export @@ -18,8 +18,6 @@ #' #' @inheritParams esp_get_ccaa #' -#' -#' #' @details #' #' Hexbin or grid map has an advantage over usual choropleth maps. @@ -27,12 +25,12 @@ #' of its size, what introduces a bias. Here with hexbin, each region is #' represented equally dismissing the bias. #' -#' You can use and mix names, ISO codes, "codauto"/"cpro" codes (see +#' You can use and mix names, ISO codes, `"codauto"/ "cpro"` codes (see #' [esp_codelist]) and NUTS codes of different levels. #' #' When using a code corresponding of a higher level (e.g. #' `esp_get_prov("Andalucia")`) all the corresponding units of that level are -#' provided (in this case , all the provinces of Andalucia). +#' provided (in this case , all the provinces of Andalusia). #' #' #' Results are provided in **EPSG:4258**, use [sf::st_transform()] @@ -155,8 +153,7 @@ esp_get_grid_ccaa <- function(ccaa = NULL) { nuts_id <- unique(nuts_id) if (length(nuts_id) == 0) { stop( - "region ", - paste0("'", region, "'", collapse = ", "), + "region ", paste0("'", region, "'", collapse = ", "), " is not a valid name" ) } diff --git a/R/esp_get_hydrobasin.R b/R/esp_get_hydrobasin.R index 48583291..6fe6373b 100644 --- a/R/esp_get_hydrobasin.R +++ b/R/esp_get_hydrobasin.R @@ -1,21 +1,22 @@ -#' Get [`sf`][sf::st_sf] polygons of the drainage basin demarcations of Spain +#' Get [`sf`][sf::st_sf] `POLYGON` of the drainage basin demarcations of Spain #' #' @description -#' Loads a [`sf`][sf::st_sf] polygon object containing areas with the required +#' Loads a [`sf`][sf::st_sf] `POLYGON` object containing areas with the required #' hydrographic elements of Spain. #' #' @family natural #' -#' @return A [`sf`][sf::st_sf] polygon object. +#' @return A [`sf`][sf::st_sf] `POLYGON` object. #' -#' @source IGN data via a custom CDN (see +#' @source +#' IGN data via a custom CDN (see #' ). #' #' @export #' #' @param domain Possible values are `"land"`, that includes only #' the ground part or the ground or `"landsea"`, that includes both the ground -#' and the related sea waters of the basin +#' and the related sea waters of the basin. #' #' @inheritParams esp_get_rivers #' @@ -50,12 +51,9 @@ #' ) + #' theme_void() #' } -esp_get_hydrobasin <- function(epsg = "4258", - cache = TRUE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - resolution = "3", +esp_get_hydrobasin <- function(epsg = "4258", cache = TRUE, + update_cache = FALSE, cache_dir = NULL, + verbose = FALSE, resolution = "3", domain = "land") { # Check epsg init_epsg <- as.character(epsg) @@ -75,19 +73,12 @@ esp_get_hydrobasin <- function(epsg = "4258", } type <- paste0("basin", domain) - basin_sf <- - esp_hlp_get_siane( - type, - resolution, - cache, - cache_dir, - update_cache, - verbose, - Sys.Date() - ) + basin_sf <- esp_hlp_get_siane( + type, resolution, cache, cache_dir, + update_cache, verbose, Sys.Date() + ) - basin_sf <- - sf::st_transform(basin_sf, as.double(init_epsg)) + basin_sf <- sf::st_transform(basin_sf, as.double(init_epsg)) return(basin_sf) } diff --git a/R/esp_get_hypsobath.R b/R/esp_get_hypsobath.R index 77a04909..336077d1 100644 --- a/R/esp_get_hypsobath.R +++ b/R/esp_get_hypsobath.R @@ -1,20 +1,21 @@ -#' Get [`sf`][sf::st_sf] polygons and lines with hypsometry and bathymetry of -#' Spain. +#' Get [`sf`][sf::st_sf] `POLYGON` or `LINESTRING` with hypsometry and +#' bathymetry of Spain #' #' @description -#' Loads a [`sf`][sf::st_sf] polygon or line object representing the hypsometry -#' and bathymetry of Spain. +#' Loads a [`sf`][sf::st_sf] `POLYGON` or `LINESTRING` object representing the +#' hypsometry and bathymetry of Spain. #' -#' * **Hypsometry** represents the the elevation and depth of features of the +#' - **Hypsometry** represents the the elevation and depth of features of the #' Earth's surface relative to mean sea level. -#' * **Bathymetry** is the measurement of the depth of water in oceans, rivers, +#' - **Bathymetry** is the measurement of the depth of water in oceans, rivers, #' or lakes. #' #' @family natural #' -#' @return A [`sf`][sf::st_sf] polygon or line object. +#' @return A [`sf`][sf::st_sf] `POLYGON` or `LINESTRING` object. #' -#' @source IGN data via a custom CDN (see +#' @source +#' IGN data via a custom CDN (see #' ). #' #' @export @@ -22,8 +23,8 @@ #' @param resolution Resolution of the shape. Values available #' are `"3"` or `"6.5"`. #' -#' @param spatialtype Spatial type of the output. Use `"area"` for polygons or -#' `"line"` for lines. +#' @param spatialtype Spatial type of the output. Use `"area"` for `POLYGON` or +#' `"line"` for `LINESTRING`. #' #' @inheritParams esp_get_nuts #' @@ -46,7 +47,8 @@ #' hypsobath <- hypsobath[!sf::st_is_empty(hypsobath), ] #' #' # Tints from Wikipedia -#' # https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Maps/Conventions/Topographic_maps +#' # https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Maps/Conventions/ +#' # Topographic_maps #' #' bath_tints <- colorRampPalette( #' rev( @@ -116,13 +118,9 @@ #' keyheight = .8 #' )) #' } -esp_get_hypsobath <- function(epsg = "4258", - cache = TRUE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - resolution = "3", - spatialtype = "area") { +esp_get_hypsobath <- function(epsg = "4258", cache = TRUE, update_cache = FALSE, + cache_dir = NULL, verbose = FALSE, + resolution = "3", spatialtype = "area") { init_epsg <- as.character(epsg) if (!init_epsg %in% c("4326", "4258", "3035", "3857")) { stop("epsg value not valid. It should be one of 4326, 4258, 3035 or 3857") @@ -133,8 +131,7 @@ esp_get_hypsobath <- function(epsg = "4258", if (!resolution %in% validres) { stop( - "resolution should be one of '", - paste0(validres, collapse = "', "), + "resolution should be one of '", paste0(validres, collapse = "', "), "'" ) } @@ -145,20 +142,16 @@ esp_get_hypsobath <- function(epsg = "4258", if (!spatialtype %in% validspatialtype) { stop( "spatialtype should be one of '", - paste0(validspatialtype, collapse = "', "), - "'" + paste0(validspatialtype, collapse = "', "), "'" ) } type <- paste0("orog", spatialtype) - data_sf <- esp_hlp_get_siane(type, - resolution, - cache, - cache_dir, - update_cache, + data_sf <- esp_hlp_get_siane(type, resolution, cache, cache_dir, update_cache, verbose, year = Sys.Date() ) + data_sf <- sf::st_transform(data_sf, as.double(init_epsg)) } diff --git a/R/esp_get_munic.R b/R/esp_get_munic.R index 30feaaac..4af47402 100644 --- a/R/esp_get_munic.R +++ b/R/esp_get_munic.R @@ -1,31 +1,28 @@ -#' Get municipalities of Spain as [`sf`][sf::st_sf] polygons +#' Get municipalities of Spain as [`sf`][sf::st_sf] `POLYGON` #' #' @description -#' Returns municipalities of Spain as polygons at a specified scale. +#' Returns municipalities of Spain `sf` POLYGON` at a specified scale. #' -#' * [esp_get_munic()] uses GISCO (Eurostat) as source. Please use -#' [giscoR::gisco_attributions()] +#' - [esp_get_munic()] uses GISCO (Eurostat) as source. Please use +#' [giscoR::gisco_attributions()]. #' #' @family political #' @family municipalities #' @seealso [giscoR::gisco_get_lau()], [base::regex()]. #' -#' @return A [`sf`][sf::st_sf] polygon +#' @return A [`sf`][sf::st_sf] `POLYGON`. #' #' @export #' -#' @source [GISCO API](https://gisco-services.ec.europa.eu/distribution/v2/) -#' -#' -#' +#' @source +#' [GISCO API](https://gisco-services.ec.europa.eu/distribution/v2/) #' #' @param year Release year. See **Details** for years available. - #' @param region A vector of names and/or codes for provinces #' or `NULL` to get all the municipalities. See **Details**. #' #' @param munic A name or [`regex`][base::grep()] expression with the names of -#' the required municipalities. `NULL` would not produce any filtering. +#' the required municipalities. `NULL` would return all municipalities. #' #' @inheritParams esp_get_nuts #' @@ -36,20 +33,19 @@ #' @details #' #' The years available are: -#' * [esp_get_munic()]: `year` could be one of "2001", "2004", "2006", "2008", +#' - [esp_get_munic()]: `year` could be one of "2001", "2004", "2006", "2008", #' "2010", "2013" and any year between 2016 and 2019. #' See [giscoR::gisco_get_lau()], [giscoR::gisco_get_communes()]. -#' -#' * [esp_get_munic_siane()]: `year` could be passed as a single year ("YYYY" +#' - [esp_get_munic_siane()]: `year` could be passed as a single year ("YYYY" #' format, as end of year) or as a specific date ("YYYY-MM-DD" format). #' Historical information starts as of 2005. #' -#' When using `region` you can use and mix names and NUTS codes -#' (levels 1, 2 or 3), ISO codes (corresponding to level 2 or 3) or -#' "cpro" (see [esp_codelist]). +#' When using `region` you can use and mix names and NUTS codes (levels 1, 2 or +#' 3), ISO codes (corresponding to level 2 or 3) or `"cpro"` +#' (see [esp_codelist]). #' -#' When calling a superior level (Province, Autonomous Community or NUTS1) , -#' all the municipalities of that level would be added. +#' When calling a higher level (Province, Autonomous Community or NUTS1), all +#' the municipalities of that level would be added. #' #' @examples #' \donttest{ @@ -92,46 +88,28 @@ #' ) + #' theme_void() #' } -esp_get_munic <- function(year = "2019", - epsg = "4258", - cache = TRUE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - region = NULL, - munic = NULL, +esp_get_munic <- function(year = "2019", epsg = "4258", cache = TRUE, + update_cache = FALSE, cache_dir = NULL, + verbose = FALSE, region = NULL, munic = NULL, moveCAN = TRUE) { init_epsg <- as.character(epsg) year <- as.character(year) - yearsav <- - c( - "2001", - "2004", - "2006", - "2008", - "2010", - "2013", - "2016", - "2017", - "2018", - "2019" - ) + yearsav <- c( + "2001", "2004", "2006", "2008", "2010", "2013", "2016", "2017", + "2018", "2019" + ) if (!year %in% yearsav) { stop( - "year ", - year, - " not available, try ", + "year ", year, " not available, try ", paste0("'", yearsav, "'", collapse = ", ") ) } cache_dir <- esp_hlp_cachedir(cache_dir) - if (init_epsg == "4258") { - epsg <- "4326" - } + if (init_epsg == "4258") epsg <- "4326" dwnload <- TRUE @@ -149,18 +127,15 @@ esp_get_munic <- function(year = "2019", if (dwnload) { if (year >= "2016") { data_sf <- giscoR::gisco_get_lau( - year = year, - epsg = epsg, + year = year, epsg = epsg, cache = cache, update_cache = update_cache, cache_dir = cache_dir, - verbose = verbose, - country = "ES" + verbose = verbose, country = "ES" ) } else { data_sf <- giscoR::gisco_get_communes( - year = year, - epsg = epsg, + year = year, epsg = epsg, cache = cache, update_cache = update_cache, cache_dir = cache_dir, @@ -206,31 +181,19 @@ esp_get_munic <- function(year = "2019", df <- df[, c("cpro", "cmun", "name", "LAU_CODE")] - cod <- - unique(mapSpain::esp_codelist[, c( - "codauto", - "ine.ccaa.name", - "cpro", "ine.prov.name" - )]) - - df2 <- merge(df, - cod, - by = "cpro", - all.x = TRUE, - no.dups = TRUE - ) + cod <- unique(mapSpain::esp_codelist[, c( + "codauto", + "ine.ccaa.name", + "cpro", "ine.prov.name" + )]) + + df2 <- merge(df, cod, by = "cpro", all.x = TRUE, no.dups = TRUE) - df2 <- - df2[, c( - "codauto", - "ine.ccaa.name", - "cpro", - "ine.prov.name", - "cmun", - "name", - "LAU_CODE" - )] + df2 <- df2[, c( + "codauto", "ine.ccaa.name", "cpro", "ine.prov.name", + "cmun", "name", "LAU_CODE" + )] data_sf <- df2 @@ -300,7 +263,7 @@ esp_get_munic <- function(year = "2019", #' #' #' @description -#' * [esp_get_munic_siane()] uses CartoBase ANE as source, provided by +#' - [esp_get_munic_siane()] uses CartoBase ANE as source, provided by #' Instituto Geografico Nacional (IGN), . #' Years available are 2005 up to today. #' @@ -315,17 +278,10 @@ esp_get_munic <- function(year = "2019", #' #' #' @export -esp_get_munic_siane <- function(year = Sys.Date(), - epsg = "4258", - cache = TRUE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - resolution = 3, - region = NULL, - munic = NULL, - moveCAN = TRUE, - rawcols = FALSE) { +esp_get_munic_siane <- function(year = Sys.Date(), epsg = "4258", cache = TRUE, + update_cache = FALSE, cache_dir = NULL, + verbose = FALSE, resolution = 3, region = NULL, + munic = NULL, moveCAN = TRUE, rawcols = FALSE) { init_epsg <- as.character(epsg) year <- as.character(year) @@ -335,13 +291,8 @@ esp_get_munic_siane <- function(year = Sys.Date(), # Get Data from SIANE data_sf <- esp_hlp_get_siane( - "munic", - resolution, - cache, - cache_dir, - update_cache, - verbose, - year + "munic", resolution, cache, cache_dir, + update_cache, verbose, year ) colnames_init <- colnames(sf::st_drop_geometry(data_sf)) @@ -358,19 +309,13 @@ esp_get_munic_siane <- function(year = Sys.Date(), NA ) - cod <- - unique(mapSpain::esp_codelist[, c( - "codauto", - "ine.ccaa.name", - "cpro", "ine.prov.name" - )]) + cod <- unique(mapSpain::esp_codelist[, c( + "codauto", + "ine.ccaa.name", + "cpro", "ine.prov.name" + )]) - df2 <- merge(df, - cod, - by = "cpro", - all.x = TRUE, - no.dups = TRUE - ) + df2 <- merge(df, cod, by = "cpro", all.x = TRUE, no.dups = TRUE) data_sf <- df2 @@ -423,12 +368,7 @@ esp_get_munic_siane <- function(year = Sys.Date(), namesend <- unique(c( colnames_init, c( - "codauto", - "ine.ccaa.name", - "cpro", - "ine.prov.name", - "cmun", - "name", + "codauto", "ine.ccaa.name", "cpro", "ine.prov.name", "cmun", "name", "LAU_CODE" ), colnames(data_sf) @@ -437,15 +377,13 @@ esp_get_munic_siane <- function(year = Sys.Date(), data_sf <- data_sf[, namesend] if (isFALSE(rawcols)) { - data_sf <- data_sf[, c( - "codauto", - "ine.ccaa.name", - "cpro", - "ine.prov.name", - "cmun", - "name", - "LAU_CODE" - )] + data_sf <- data_sf[ + , + c( + "codauto", "ine.ccaa.name", "cpro", "ine.prov.name", + "cmun", "name", "LAU_CODE" + ) + ] } return(data_sf) } diff --git a/R/esp_get_nuts.R b/R/esp_get_nuts.R index 950fe8e7..7f1372fc 100644 --- a/R/esp_get_nuts.R +++ b/R/esp_get_nuts.R @@ -1,18 +1,18 @@ -#' Get NUTS of Spain as [`sf`][sf::st_sf] polygons and points +#' Get NUTS of Spain as [`sf`][sf::st_sf] `POLYGON` or `POINT` #' #' @description #' Returns [NUTS regions of #' Spain](https://en.wikipedia.org/wiki/NUTS_statistical_regions_of_Spain) -#' as polygons and points at a specified scale, as provided by +#' as `POLYGON` or `POINT` at a specified scale, as provided by #' [GISCO](https://ec.europa.eu/eurostat/web/gisco) #' (Geographic Information System of the Commission, depending of Eurostat). #' #' NUTS are provided at three different levels: -#' * **"0"**: Country level -#' * **"1"**: Groups of autonomous communities -#' * **"2"**: Autonomous communities -#' * **"3"**: Roughly matches the provinces, but providing specific individual -#' objects for each major island +#' - **"0"**: Country level. +#' - **"1"**: Groups of autonomous communities. +#' - **"2"**: Autonomous communities (CCAA). +#' - **"3"**: Roughly matches the provinces, but providing specific individual +#' objects for each major island. #' #' @export #' @@ -26,18 +26,18 @@ #' Please check the download and usage provisions on #' [giscoR::gisco_attributions()] #' -#' @source [GISCO API](https://gisco-services.ec.europa.eu/distribution/v2/) +#' @source +#' [GISCO API](https://gisco-services.ec.europa.eu/distribution/v2/) #' #' #' @param year Release year of the file. One of `"2003"`, `"2006"`, #' `"2010"`, `"2013"`, `"2016"` or `"2021"`. -#' #' @param epsg projection of the map: 4-digit [EPSG code](https://epsg.io/). #' One of: -#' * `"4258"`: ETRS89 -#' * `"4326"`: WGS84 -#' * `"3035"`: ETRS89 / ETRS-LAEA -#' * `"3857"`: Pseudo-Mercator +#' - `"4258"`: ETRS89. +#' - `"4326"`: WGS84. +#' - `"3035"`: ETRS89 / ETRS-LAEA. +#' - `"3857"`: Pseudo-Mercator. #' #' @param cache A logical whether to do caching. Default is `TRUE`. See #' **About caching**. @@ -51,21 +51,21 @@ #' default is `FALSE`. #' #' @param resolution Resolution of the geospatial data. One of -#' * "60": 1:60million -#' * "20": 1:20million -#' * "10": 1:10million -#' * "03": 1:3million -#' * "01": 1:1million +#' - `"60"`: 1:60million +#' - `"20"`: 1:20million +#' - `"10"`: 1:10million +#' - `"03"`: 1:3million +#' - `"01"`: 1:1million #' #' @param spatialtype Type of geometry to be returned: -#' * `"LB"`: Labels - point object. -#' * `"RG"`: Regions - polygon object. +#' - `"LB"`: Labels - `POINT` object. +#' - `"RG"`: Regions - `POLYGON` object. #' #' @param region Optional. A vector of region names, NUTS or ISO codes #' (see [esp_dict_region_code()]). #' -#' @param nuts_level NUTS level. One of "0" (Country-level), "1", "2" or "3". -#' See **Description**. +#' @param nuts_level NUTS level. One of `"0"` (Country-level), `"1"`, `"2"` or +#' `"3"`. See **Description**. #' #' @param moveCAN A logical `TRUE/FALSE` or a vector of coordinates #' `c(lat, lon)`. It places the Canary Islands close to Spain's mainland. @@ -84,7 +84,6 @@ #' corresponding .geojson file by any other method and save it on your #' `cache_dir`. Use the option `verbose = TRUE` for debugging the API query. #' -#' #' # Displacing the Canary Islands #' #' While `moveCAN` is useful for visualization, it would alter the actual @@ -131,8 +130,10 @@ #' ) #' #' -#' AndOriental <- -#' esp_get_nuts(region = c("Almeria", "Granada", "Jaen", "Malaga")) +#' AndOriental <- esp_get_nuts(region = c( +#' "Almeria", "Granada", +#' "Jaen", "Malaga" +#' )) #' #' #' ggplot(AndOriental) + @@ -153,17 +154,10 @@ #' ggplot(MixingCodes) + #' geom_sf() + #' labs(title = "Mixing Codes") -esp_get_nuts <- function(year = "2016", - epsg = "4258", - cache = TRUE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - resolution = "01", - spatialtype = "RG", - region = NULL, - nuts_level = "all", - moveCAN = TRUE) { +esp_get_nuts <- function(year = "2016", epsg = "4258", cache = TRUE, + update_cache = FALSE, cache_dir = NULL, + verbose = FALSE, resolution = "01", spatialtype = "RG", + region = NULL, nuts_level = "all", moveCAN = TRUE) { init_epsg <- as.character(epsg) year <- as.character(year) resolution <- as.character(resolution) @@ -212,14 +206,12 @@ esp_get_nuts <- function(year = "2016", if (length(nuts_id) == 0) { stop( - "region ", - paste0("'", region, "'", collapse = ", "), + "region ", paste0("'", region, "'", collapse = ", "), " is not a valid name" ) } } - dwnload <- TRUE if (all( @@ -245,16 +237,13 @@ esp_get_nuts <- function(year = "2016", if (dwnload) { data_sf <- giscoR::gisco_get_nuts( - resolution = resolution, - year = year, - epsg = epsg, - nuts_level = nuts_level, + resolution = resolution, year = year, + epsg = epsg, nuts_level = nuts_level, cache = cache, update_cache = update_cache, cache_dir = cache_dir, spatialtype = spatialtype, - nuts_id = nuts_id, - country = "ES", + nuts_id = nuts_id, country = "ES", verbose = verbose ) } diff --git a/R/esp_get_prov.R b/R/esp_get_prov.R index cff739e5..a429f225 100644 --- a/R/esp_get_prov.R +++ b/R/esp_get_prov.R @@ -1,11 +1,11 @@ -#' Get Provinces of Spain as [`sf`][sf::st_sf] polygons and points +#' Get Provinces of Spain as [`sf`][sf::st_sf] `POLYGON` or `POINT` #' #' @description #' Returns #' [provinces of Spain](https://en.wikipedia.org/wiki/Provinces_of_Spain) -#' as polygons and points at a specified scale. +#' as `POLYGON` or `POINT` at a specified scale. #' -#' * [esp_get_prov()] uses GISCO (Eurostat) as source. Please use +#' - [esp_get_prov()] uses GISCO (Eurostat) as source. Please use #' [giscoR::gisco_attributions()] #' #' @@ -19,8 +19,8 @@ #' #' @export #' -#' @param prov A vector of names and/or codes for provinces -#' or `NULL` to get all the provinces. See **Details**. +#' @param prov A vector of names and/or codes for provinces or `NULL` to get all +#' the provinces. See **Details**. #' #' @inheritDotParams esp_get_nuts -nuts_level -region #' @@ -31,8 +31,8 @@ #' #' Ceuta and Melilla are considered as provinces on this dataset. #' -#' When calling a superior level (Autonomous Community or NUTS1) , -#' all the provinces of that level would be added. +#' When calling a higher level (Autonomous Community or NUTS1), all the +#' provinces of that level would be added. #' #' @inheritSection esp_get_nuts About caching #' @@ -50,14 +50,10 @@ #' \donttest{ #' # Random Provinces #' -#' Random <- -#' esp_get_prov(prov = c( -#' "Zamora", -#' "Palencia", -#' "ES-GR", -#' "ES521", -#' "01" -#' )) +#' Random <- esp_get_prov(prov = c( +#' "Zamora", "Palencia", "ES-GR", +#' "ES521", "01" +#' )) #' #' #' ggplot(Random) + @@ -223,14 +219,10 @@ esp_get_prov <- function(prov = NULL, moveCAN = TRUE, ...) { "nuts1.name" )]) data_sf <- merge(data_sf, dfnuts, all.x = TRUE) - data_sf <- - data_sf[, c( - colnames(df), - "nuts2.code", - "nuts2.name", - "nuts1.code", - "nuts1.name" - )] + data_sf <- data_sf[, c( + colnames(df), "nuts2.code", "nuts2.name", + "nuts1.code", "nuts1.name" + )] # Order data_sf <- data_sf[order(data_sf$codauto, data_sf$cpro), ] @@ -248,9 +240,9 @@ esp_get_prov <- function(prov = NULL, moveCAN = TRUE, ...) { #' #' #' @description -#' * [esp_get_prov_siane()] uses CartoBase ANE as source, provided by Instituto -#' Geografico Nacional (IGN), . Years -#' available are 2005 up to today. +#' - [esp_get_prov_siane()] uses CartoBase ANE as source, provided by Instituto +#' Geografico Nacional (IGN), . Years +#' available are 2005 up to today. #' #' @source #' IGN data via a custom CDN (see @@ -259,7 +251,7 @@ esp_get_prov <- function(prov = NULL, moveCAN = TRUE, ...) { #' @export #' #' @param year Release year. See [esp_get_nuts()] for [esp_get_prov()] and -#' **Details** for [esp_get_prov_siane()] +#' **Details** for [esp_get_prov_siane()]. #' #' @inheritParams esp_get_ccaa #' @@ -267,15 +259,10 @@ esp_get_prov <- function(prov = NULL, moveCAN = TRUE, ...) { #' On [esp_get_prov_siane()], `year` could be passed as a single year ("YYYY" #' format, as end of year) or as a specific date ("YYYY-MM-DD" format). #' Historical information starts as of 2005. -esp_get_prov_siane <- function(prov = NULL, - year = Sys.Date(), - epsg = "4258", - cache = TRUE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - resolution = "3", - moveCAN = TRUE, +esp_get_prov_siane <- function(prov = NULL, year = Sys.Date(), epsg = "4258", + cache = TRUE, update_cache = FALSE, + cache_dir = NULL, verbose = FALSE, + resolution = "3", moveCAN = TRUE, rawcols = FALSE) { init_epsg <- as.character(epsg) year <- as.character(year) @@ -287,13 +274,8 @@ esp_get_prov_siane <- function(prov = NULL, # Get Data from SIANE data_sf <- esp_hlp_get_siane( - "prov", - resolution, - cache, - cache_dir, - update_cache, - verbose, - year + "prov", resolution, cache, cache_dir, + update_cache, verbose, year ) @@ -327,14 +309,10 @@ esp_get_prov_siane <- function(prov = NULL, # Paste nuts2 dfnuts <- mapSpain::esp_codelist - dfnuts <- - unique(dfnuts[, c( - "cpro", - "nuts2.code", - "nuts2.name", - "nuts1.code", - "nuts1.name" - )]) + dfnuts <- unique(dfnuts[, c( + "cpro", "nuts2.code", "nuts2.name", "nuts1.code", + "nuts1.name" + )]) data_sf <- merge(data_sf, dfnuts, all.x = TRUE) diff --git a/R/esp_get_railway.R b/R/esp_get_railway.R index a92d2791..537f01a7 100644 --- a/R/esp_get_railway.R +++ b/R/esp_get_railway.R @@ -1,12 +1,12 @@ -#' Get [`sf`][sf::st_sf] lines and points with the railways of Spain +#' Get [`sf`][sf::st_sf] `LINESTRING` or `POINT` with the railways of Spain #' #' @description -#' Loads a [`sf`][sf::st_sf] lines or point object representing the nodes and -#' railway lines of Spain. +#' Loads a [`sf`][sf::st_sf] `LINESTRING` or `POINT` object representing the +#' nodes and railway lines of Spain. #' #' @family infrastructure #' -#' @return A [`sf`][sf::st_sf] line or point object. +#' @return A [`sf`][sf::st_sf] `LINESTRING` or `POINT` object. #' #' @source IGN data via a custom CDN (see #' ). @@ -59,13 +59,9 @@ #' )) + #' theme_minimal() #' } -esp_get_railway <- function(year = Sys.Date(), - epsg = "4258", - cache = TRUE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - spatialtype = "line") { +esp_get_railway <- function(year = Sys.Date(), epsg = "4258", cache = TRUE, + update_cache = FALSE, cache_dir = NULL, + verbose = FALSE, spatialtype = "line") { init_epsg <- as.character(epsg) year <- as.character(year) @@ -88,11 +84,7 @@ esp_get_railway <- function(year = Sys.Date(), type <- paste0("ffcc", spatialtype) - data_sf <- esp_hlp_get_siane(type, - "3", - cache, - cache_dir, - update_cache, + data_sf <- esp_hlp_get_siane(type, "3", cache, cache_dir, update_cache, verbose, year = Sys.Date() ) diff --git a/R/esp_get_rivers.R b/R/esp_get_rivers.R index 52d1e2c7..f987cb8d 100644 --- a/R/esp_get_rivers.R +++ b/R/esp_get_rivers.R @@ -1,13 +1,13 @@ -#' Get [`sf`][sf::st_sf] polygon and lines of rivers, channels and other +#' Get [`sf`][sf::st_sf] `POLYGON` or `LINESTRING` of rivers, channels and other #' wetlands of Spain #' #' @description -#' Loads a [`sf`][sf::st_sf] polygon or line object representing rivers, -#' channels, reservoirs and other wetlands of Spain. +#' Loads a [`sf`][sf::st_sf] `POLYGON` or `LINESTRING` object representing +#' rivers, channels, reservoirs and other wetlands of Spain. #' #' @family natural #' -#' @return A [`sf`][sf::st_sf] polygon or line object. +#' @return A [`sf`][sf::st_sf] `POLYGON` or `LINESTRING` object. #' #' #' @source IGN data via a custom CDN (see @@ -15,7 +15,7 @@ #' #' @export #' -#' @param resolution Resolution of the polygon. Values available are +#' @param resolution Resolution of the `POLYGON`. Values available are #' `"3"`, `"6.5"` or `"10"`. #' #' @inheritParams esp_get_hypsobath @@ -75,14 +75,9 @@ #' ) + #' theme_void() #' } -esp_get_rivers <- function(epsg = "4258", - cache = TRUE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - resolution = "3", - spatialtype = "line", - name = NULL) { +esp_get_rivers <- function(epsg = "4258", cache = TRUE, update_cache = FALSE, + cache_dir = NULL, verbose = FALSE, resolution = "3", + spatialtype = "line", name = NULL) { # Check epsg init_epsg <- as.character(epsg) if (!init_epsg %in% c("4326", "4258", "3035", "3857")) { @@ -103,39 +98,22 @@ esp_get_rivers <- function(epsg = "4258", type <- paste0("river", spatialtype) # Get shape - rivers_sf <- - esp_hlp_get_siane( - type, - resolution, - cache, - cache_dir, - update_cache, - verbose, - Sys.Date() - ) + rivers_sf <- esp_hlp_get_siane( + type, resolution, cache, cache_dir, + update_cache, verbose, Sys.Date() + ) # Get river names - rivernames <- - esp_hlp_get_siane( - "rivernames", - resolution, - cache, - cache_dir, - update_cache, - verbose, - Sys.Date() - ) - - + rivernames <- esp_hlp_get_siane( + "rivernames", resolution, cache, cache_dir, + update_cache, verbose, Sys.Date() + ) # Merge names rivernames$id_rio <- rivernames$PFAFRIO rivernames <- rivernames[, c("id_rio", "NOM_RIO")] - rivers_sf_merge <- merge(rivers_sf, - rivernames, - all.x = TRUE - ) + rivers_sf_merge <- merge(rivers_sf, rivernames, all.x = TRUE) if (!is.null(name)) { getrows1 <- grep(name, rivers_sf_merge$rotulo) @@ -145,22 +123,19 @@ esp_get_rivers <- function(epsg = "4258", if (nrow(rivers_sf_merge) == 0) { stop( - "Your value '", - name, - "' for name does not produce any result ", - "for spatialtype = '", - spatialtype, - "'" + "Your value '", name, "' for name does not produce any result ", + "for spatialtype = '", spatialtype, "'" ) } } if (spatialtype == "area") { - rivers_sf_merge <- - rivers_sf_merge[, -match("NOM_RIO", colnames(rivers_sf_merge))] + rivers_sf_merge <- rivers_sf_merge[, -match( + "NOM_RIO", + colnames(rivers_sf_merge) + )] } - rivers_sf_merge <- - sf::st_transform(rivers_sf_merge, as.double(init_epsg)) + rivers_sf_merge <- sf::st_transform(rivers_sf_merge, as.double(init_epsg)) return(rivers_sf_merge) } diff --git a/R/esp_get_roads.R b/R/esp_get_roads.R index ad4a87f7..40f49a4b 100644 --- a/R/esp_get_roads.R +++ b/R/esp_get_roads.R @@ -1,11 +1,12 @@ -#' Get [`sf`][sf::st_sf] lines of the roads of Spain +#' Get [`sf`][sf::st_sf] `LINESTRING` of the roads of Spain #' #' @description -#' Loads a [`sf`][sf::st_sf] line object representing the main roads of Spain. +#' Loads a [`sf`][sf::st_sf] `LINESTRING` object representing the main roads of +#' Spain. #' #' @family infrastructure #' -#' @return A [`sf`][sf::st_sf] line object. +#' @return A [`sf`][sf::st_sf] `LINESTRING` object. #' #' @source IGN data via a custom CDN (see #' ). @@ -43,13 +44,9 @@ #' labs(color = "Road type") + #' theme(legend.position = "bottom") #' } -esp_get_roads <- function(year = Sys.Date(), - epsg = "4258", - cache = TRUE, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE, - moveCAN = TRUE) { +esp_get_roads <- function(year = Sys.Date(), epsg = "4258", cache = TRUE, + update_cache = FALSE, cache_dir = NULL, + verbose = FALSE, moveCAN = TRUE) { init_epsg <- as.character(epsg) year <- as.character(year) @@ -59,13 +56,8 @@ esp_get_roads <- function(year = Sys.Date(), # Get Data from SIANE data_sf <- esp_hlp_get_siane( - "roads", - 3, - cache, - cache_dir, - update_cache, - verbose, - year + "roads", 3, cache, cache_dir, update_cache, + verbose, year ) diff --git a/R/esp_get_simplified.R b/R/esp_get_simplified.R index 758f7e13..06b418bb 100644 --- a/R/esp_get_simplified.R +++ b/R/esp_get_simplified.R @@ -11,7 +11,7 @@ #' #' @family political #' -#' @return A [`sf`][sf::st_sf] POLYGON object. +#' @return A [`sf`][sf::st_sf] `POLYGON` object. #' #' @inheritParams esp_get_prov #' @@ -27,12 +27,12 @@ #' #' Results are provided **without CRS**, as provided on source. #' -#' You can use and mix names, ISO codes, "codauto"/"cpro" codes (see +#' You can use and mix names, ISO codes, `"codauto"/"cpro"` codes (see #' [esp_codelist]) and NUTS codes of different levels. #' #' When using a code corresponding of a higher level (e.g. #' `esp_get_simpl_prov("Andalucia")`) all the corresponding units of that level -#' are provided (in this case , all the provinces of Andalucia). +#' are provided (in this case , all the provinces of Andalusia). #' #' @examplesIf esp_check_access() #' \donttest{ @@ -59,10 +59,8 @@ #' geom_sf() + #' geom_sf_text(aes(label = ine.ccaa.name), check_overlap = TRUE) #' } -esp_get_simpl_prov <- function(prov = NULL, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE) { +esp_get_simpl_prov <- function(prov = NULL, update_cache = FALSE, + cache_dir = NULL, verbose = FALSE) { region <- prov # Url @@ -73,14 +71,11 @@ esp_get_simpl_prov <- function(prov = NULL, data_sf <- esp_hlp_dwnload_sianedata( api_entry = api_entry, filename = filename, - cache_dir = cache_dir, - verbose = verbose, + cache_dir = cache_dir, verbose = verbose, update_cache = update_cache, cache = TRUE ) - - region <- unique(region) @@ -98,8 +93,7 @@ esp_get_simpl_prov <- function(prov = NULL, dfcpro <- mapSpain::esp_codelist dfcpro <- unique(dfcpro[, c("nuts3.code", "cpro")]) - cprocodes <- - unique(dfcpro[dfcpro$nuts3.code %in% region, ]$cpro) + cprocodes <- unique(dfcpro[dfcpro$nuts3.code %in% region, ]$cpro) data_sf <- data_sf[data_sf$cpro %in% cprocodes, ] } @@ -116,10 +110,8 @@ esp_get_simpl_prov <- function(prov = NULL, #' @rdname esp_get_simplified #' #' @export -esp_get_simpl_ccaa <- function(ccaa = NULL, - update_cache = FALSE, - cache_dir = NULL, - verbose = FALSE) { +esp_get_simpl_ccaa <- function(ccaa = NULL, update_cache = FALSE, + cache_dir = NULL, verbose = FALSE) { region <- ccaa # Url @@ -130,8 +122,7 @@ esp_get_simpl_ccaa <- function(ccaa = NULL, data_sf <- esp_hlp_dwnload_sianedata( api_entry = api_entry, filename = filename, - cache_dir = cache_dir, - verbose = verbose, + cache_dir = cache_dir, verbose = verbose, update_cache = update_cache, cache = TRUE ) @@ -154,8 +145,7 @@ esp_get_simpl_ccaa <- function(ccaa = NULL, codauto <- codauto[!is.na(codauto)] if (length(codauto) == 0) { stop( - "region ", - paste0("'", region, "'", collapse = ", "), + "region ", paste0("'", region, "'", collapse = ", "), " is not a valid name" ) } diff --git a/R/esp_make_provider.R b/R/esp_make_provider.R index 33a5c466..c78cd89d 100644 --- a/R/esp_make_provider.R +++ b/R/esp_make_provider.R @@ -18,11 +18,11 @@ #' @param id An identifier for the user. Would be used also for identifying #' cached tiles. #' -#' @param q The base url of the service +#' @param q The base url of the service. #' #' @param service The type of tile service, either `"WMS"` or `"WMTS"`. #' -#' @param layers The name of the layer to retrieve +#' @param layers The name of the layer to retrieve. #' #' @param ... Additional parameters to the query, like `version`, `format`, #' `crs/srs`, `style`, ... depending on the capabilities of the service. @@ -47,6 +47,7 @@ #' id = "an_id_for_caching", #' q = "https://idecyl.jcyl.es/geoserver/ge/wms?", #' service = "WMS", +#' version = "1.3.0", #' layers = "geolog_cyl_litologia" #' ) #' @@ -68,34 +69,25 @@ esp_make_provider <- function(id, q, service, layers, ...) { if (toupper(service) == "WMS") { def_params <- list( - q = q, - request = "GetMap", - service = "WMS", - version = "1.0.0", - format = "image/png", - layers = layers, - styles = "" + q = q, request = "GetMap", service = "WMS", + format = "image/png", layers = layers, styles = "" ) } else { def_params <- list( - q = q, - request = "GetTile", - service = "WMTS", - version = "1.0.0", - format = "image/png", - layer = layers, - style = "", - tilematrixset = "GoogleMapsCompatible" + q = q, request = "GetTile", service = "WMTS", + version = "1.0.0", format = "image/png", layer = layers, + style = "", tilematrixset = "GoogleMapsCompatible" ) } # Modify end <- modifyList(def_params, dots) + # Here adjust crs values if (end$service == "WMS") { - if (end$version < "1.3.0") { + if (all(!is.null(end$version), end$version < "1.3.0")) { names(end) <- gsub("crs", "srs", names(end)) end$srs <- ifelse(is.null(end$srs), "EPSG:3857", end$srs) } else { diff --git a/README.Rmd b/README.Rmd index da7f22c3..86d2100f 100644 --- a/README.Rmd +++ b/README.Rmd @@ -81,8 +81,7 @@ install.packages("mapSpain", Alternatively, you can install the developing version of **mapSpain** with: ```{r, eval = FALSE} -library(remotes) -install_github("rOpenSpain/mapSpain", dependencies = TRUE) +remotes::install_github("rOpenSpain/mapSpain", dependencies = TRUE) ``` ## Usage @@ -92,80 +91,69 @@ This script highlights some features of **mapSpain** : ```{r static} library(mapSpain) library(sf) +library(dplyr) census <- mapSpain::pobmun19 # Extract CCAA from base dataset -codelist <- mapSpain::esp_codelist - -census <- - unique(merge(census, codelist[, c("cpro", "codauto")], all.x = TRUE)) - -# Summarize by CCAA -census_ccaa <- - aggregate(cbind(pob19, men, women) ~ codauto, data = census, sum) +codelist <- mapSpain::esp_codelist %>% + select(cpro, codauto) %>% + distinct() + +census_ccaa <- census %>% + left_join(codelist) %>% + # Summarize by CCAA + group_by(codauto) %>% + summarise(pob19 = sum(pob19), men = sum(men), women = sum(women)) %>% + mutate( + porc_women = women / pob19, + porc_women_lab = paste0(round(100 * porc_women, 2), "%") + ) -census_ccaa$porc_women <- census_ccaa$women / census_ccaa$pob19 -census_ccaa$porc_women_lab <- - paste0(round(100 * census_ccaa$porc_women, 2), "%") # Merge into spatial data -CCAA_sf <- esp_get_ccaa() -CCAA_sf <- merge(CCAA_sf, census_ccaa) -Can <- esp_get_can_box() +ccaa_sf <- esp_get_ccaa() %>% + left_join(census_ccaa) +can <- esp_get_can_box() # Plot with ggplot library(ggplot2) -ggplot(CCAA_sf) + - geom_sf(aes(fill = porc_women), - color = "grey70", - linewidth = .3 - ) + - geom_sf(data = Can, color = "grey70") + +ggplot(ccaa_sf) + + geom_sf(aes(fill = porc_women), color = "grey70", linewidth = .3) + + geom_sf(data = can, color = "grey70") + geom_sf_label(aes(label = porc_women_lab), fill = "white", alpha = 0.5, - size = 3, - label.size = 0 + size = 3, label.size = 0 ) + scale_fill_gradientn( colors = hcl.colors(10, "Blues", rev = TRUE), - n.breaks = 10, - labels = function(x) { - sprintf("%1.1f%%", 100 * x) - }, - guide = guide_legend(title = "Porc. women") + n.breaks = 10, labels = scales::label_percent(), + guide = guide_legend(title = "Porc. women", position = "inside") ) + theme_void() + - theme(legend.position = c(0.1, 0.6)) + theme(legend.position.inside = c(0.1, 0.6)) ``` You can combine `sf` objects with static tiles ```{r tile} # Get census -census <- mapSpain::pobmun19 -census$porc_women <- census$women / census$pob19 +census <- mapSpain::pobmun19 %>% + mutate(porc_women = women / pob19) %>% + select(cpro, cmun, porc_women) # Get shapes shape <- esp_get_munic_siane(region = "Segovia", epsg = 3857) provs <- esp_get_prov_siane(epsg = 3857) -shape_pop <- merge(shape, - census, - by = c("cpro", "cmun"), - all.x = TRUE -) +shape_pop <- shape %>% left_join(census) -tile <- - esp_getTiles(shape_pop, - type = "IGNBase.Todo", - zoommin = 1 - ) +tile <- esp_getTiles(shape_pop, type = "IGNBase.Todo", zoommin = 1) # Plot @@ -214,19 +202,13 @@ library(giscoR) res <- "20" -all_countries <- gisco_get_countries( - resolution = res -) |> +all_countries <- gisco_get_countries(resolution = res) %>% st_transform(3035) -eu_countries <- gisco_get_countries( - resolution = res, region = "EU" -) |> +eu_countries <- gisco_get_countries(resolution = res, region = "EU") %>% st_transform(3035) -ccaa <- esp_get_ccaa( - moveCAN = FALSE, resolution = res -) |> +ccaa <- esp_get_ccaa(moveCAN = FALSE, resolution = res) %>% st_transform(3035) library(ggplot2) @@ -236,16 +218,10 @@ ggplot(all_countries) + geom_sf(data = eu_countries, fill = "#FDFBEA", color = "#656565") + geom_sf(data = ccaa, fill = "#C12838", color = "grey80", linewidth = .1) + # Center in Europe: EPSG 3035 - coord_sf( - xlim = c(2377294, 7453440), - ylim = c(1313597, 5628510) - ) + + coord_sf(xlim = c(2377294, 7453440), ylim = c(1313597, 5628510)) + theme( panel.background = element_blank(), - panel.grid = element_line( - colour = "#DFDFDF", - linetype = "dotted" - ) + panel.grid = element_line(colour = "#DFDFDF", linetype = "dotted") ) ``` diff --git a/README.md b/README.md index 490f750e..842d9923 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,7 @@ Alternatively, you can install the developing version of **mapSpain** with: ``` r -library(remotes) -install_github("rOpenSpain/mapSpain", dependencies = TRUE) +remotes::install_github("rOpenSpain/mapSpain", dependencies = TRUE) ``` ## Usage @@ -67,55 +66,51 @@ This script highlights some features of **mapSpain** : ``` r library(mapSpain) library(sf) +library(dplyr) census <- mapSpain::pobmun19 # Extract CCAA from base dataset -codelist <- mapSpain::esp_codelist - -census <- - unique(merge(census, codelist[, c("cpro", "codauto")], all.x = TRUE)) - -# Summarize by CCAA -census_ccaa <- - aggregate(cbind(pob19, men, women) ~ codauto, data = census, sum) +codelist <- mapSpain::esp_codelist %>% + select(cpro, codauto) %>% + distinct() + +census_ccaa <- census %>% + left_join(codelist) %>% + # Summarize by CCAA + group_by(codauto) %>% + summarise(pob19 = sum(pob19), men = sum(men), women = sum(women)) %>% + mutate( + porc_women = women / pob19, + porc_women_lab = paste0(round(100 * porc_women, 2), "%") + ) -census_ccaa$porc_women <- census_ccaa$women / census_ccaa$pob19 -census_ccaa$porc_women_lab <- - paste0(round(100 * census_ccaa$porc_women, 2), "%") # Merge into spatial data -CCAA_sf <- esp_get_ccaa() -CCAA_sf <- merge(CCAA_sf, census_ccaa) -Can <- esp_get_can_box() +ccaa_sf <- esp_get_ccaa() %>% + left_join(census_ccaa) +can <- esp_get_can_box() # Plot with ggplot library(ggplot2) -ggplot(CCAA_sf) + - geom_sf(aes(fill = porc_women), - color = "grey70", - linewidth = .3 - ) + - geom_sf(data = Can, color = "grey70") + +ggplot(ccaa_sf) + + geom_sf(aes(fill = porc_women), color = "grey70", linewidth = .3) + + geom_sf(data = can, color = "grey70") + geom_sf_label(aes(label = porc_women_lab), fill = "white", alpha = 0.5, - size = 3, - label.size = 0 + size = 3, label.size = 0 ) + scale_fill_gradientn( colors = hcl.colors(10, "Blues", rev = TRUE), - n.breaks = 10, - labels = function(x) { - sprintf("%1.1f%%", 100 * x) - }, - guide = guide_legend(title = "Porc. women") + n.breaks = 10, labels = scales::label_percent(), + guide = guide_legend(title = "Porc. women", position = "inside") ) + theme_void() + - theme(legend.position = c(0.1, 0.6)) + theme(legend.position.inside = c(0.1, 0.6)) ``` @@ -124,25 +119,18 @@ You can combine `sf` objects with static tiles ``` r # Get census -census <- mapSpain::pobmun19 -census$porc_women <- census$women / census$pob19 +census <- mapSpain::pobmun19 %>% + mutate(porc_women = women / pob19) %>% + select(cpro, cmun, porc_women) # Get shapes shape <- esp_get_munic_siane(region = "Segovia", epsg = 3857) provs <- esp_get_prov_siane(epsg = 3857) -shape_pop <- merge(shape, - census, - by = c("cpro", "cmun"), - all.x = TRUE -) +shape_pop <- shape %>% left_join(census) -tile <- - esp_getTiles(shape_pop, - type = "IGNBase.Todo", - zoommin = 1 - ) +tile <- esp_getTiles(shape_pop, type = "IGNBase.Todo", zoommin = 1) # Plot @@ -194,19 +182,13 @@ library(giscoR) res <- "20" -all_countries <- gisco_get_countries( - resolution = res -) |> +all_countries <- gisco_get_countries(resolution = res) %>% st_transform(3035) -eu_countries <- gisco_get_countries( - resolution = res, region = "EU" -) |> +eu_countries <- gisco_get_countries(resolution = res, region = "EU") %>% st_transform(3035) -ccaa <- esp_get_ccaa( - moveCAN = FALSE, resolution = res -) |> +ccaa <- esp_get_ccaa(moveCAN = FALSE, resolution = res) %>% st_transform(3035) library(ggplot2) @@ -216,16 +198,10 @@ ggplot(all_countries) + geom_sf(data = eu_countries, fill = "#FDFBEA", color = "#656565") + geom_sf(data = ccaa, fill = "#C12838", color = "grey80", linewidth = .1) + # Center in Europe: EPSG 3035 - coord_sf( - xlim = c(2377294, 7453440), - ylim = c(1313597, 5628510) - ) + + coord_sf(xlim = c(2377294, 7453440), ylim = c(1313597, 5628510)) + theme( panel.background = element_blank(), - panel.grid = element_line( - colour = "#DFDFDF", - linetype = "dotted" - ) + panel.grid = element_line(colour = "#DFDFDF", linetype = "dotted") ) ``` diff --git a/codemeta.json b/codemeta.json index 1293026d..1de81468 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.882KB", + "fileSize": "2419.184KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/data/esp_codelist.rda b/data/esp_codelist.rda index f84840d6..e3895183 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 568cc95d..4984dc91 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 7b7d89f0..fa207d0e 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 66401a9e..2b05dc6e 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 5c679a21..50591e1c 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 14ad3f94..0ff4fb59 100644 Binary files a/img/README-tile-1.png and b/img/README-tile-1.png differ diff --git a/inst/WORDLIST b/inst/WORDLIST index a6443217..7119d976 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -8,39 +8,28 @@ Bathymetry CCAA CDN CLDR -CMD CRS Canarias CartoBase Centre Ceuta -Choropleth Comarcas -DOI Datos EEA EPSG ESDAC ETRS -Espaciales -España Estadistica -EuroGeographics Eurostat FID GISCO Galician -Geodata Geografico -Geográfico -HOTFIX Hexbin Hypsometry IDEE -IDERioja IGN INE -Infraestructura Instituto LAEA LAU @@ -55,75 +44,44 @@ Naturaleza OGC ORCID OpenStreetMap -OpenStreetMaps Panagos -Precompute -QUICKFIX -README REGCAN RGBA RegCan Renviron -Rioja's SIANE -Tenerife Topografico URBN -Verwaltungsgrenzen WGS WMS WMTS +WMTSproviders YYYY -administratives alboran -basemaps bathymetry -bezüglich -ccaa -centroid ceuta choropleth choropleths -cldr cmun codauto -codecov -codelist comarcas config cpro de -der dir ec esdac eu europa -ga geojson geospatial -ggplot -giscoR hexbin hydrographic hypsometry -ign -ine -iso javascript jrc kms -lang -les -limites -mapsf melilla -param pre providersESP -rOS -roxygen -shortname spanish -tidyterra -tmap diff --git a/inst/examples/esp_munic_sf.R b/inst/examples/esp_munic_sf.R index e939251a..67a80802 100644 --- a/inst/examples/esp_munic_sf.R +++ b/inst/examples/esp_munic_sf.R @@ -16,6 +16,7 @@ ggplot(teruel_sf) + values = "#C12838", labels = "City of Teruel" ) + + guides(fill = guide_legend(position = "inside")) + labs( fill = "", title = "Municipalities of Teruel" @@ -25,5 +26,5 @@ ggplot(teruel_sf) + text = element_text(face = "bold"), panel.background = element_rect(colour = "black"), panel.grid = element_blank(), - legend.position = c(.2, .95) + legend.position.inside = c(.2, .95) ) diff --git a/inst/examples/esp_nuts_sf.R b/inst/examples/esp_nuts_sf.R index b4d71576..718d64c4 100644 --- a/inst/examples/esp_nuts_sf.R +++ b/inst/examples/esp_nuts_sf.R @@ -26,7 +26,4 @@ ggplot(nuts3) + title = "NUTS3 levels of Spain", fill = "Urban topology" ) + - theme_linedraw() + - theme( - legend.position = c(.8, .2) - ) + theme_linedraw() diff --git a/man/addProviderEspTiles.Rd b/man/addProviderEspTiles.Rd index 1322ddd8..fdde8e4f 100644 --- a/man/addProviderEspTiles.Rd +++ b/man/addProviderEspTiles.Rd @@ -21,21 +21,19 @@ addProviderEspTiles( providerEspTileOptions(...) } \arguments{ -\item{map}{A map widget created from \code{\link[leaflet:leaflet]{leaflet::leaflet()}}.} +\item{map}{the map to add the tile layer to} \item{provider}{Name of the provider, see \link{esp_tiles_providers} for values available.} -\item{layerId}{the layer id} +\item{layerId}{the layer id to assign} -\item{group}{The name of the group the newly created layers should belong to -Human-friendly group names are permitted–they need not be short, -identifier-style names. Any number of layers and even different types of -layers (e.g. markers and polygons) can share the same group name. See -\code{\link[leaflet:map-layers]{leaflet::addTiles()}}.} +\item{group}{the name of the group the newly created layers should belong to +(for \code{\link[leaflet]{clearGroup}} and \code{\link[leaflet]{addLayersControl}} purposes). +Human-friendly group names are permitted--they need not be short, +identifier-style names.} -\item{options}{a list of extra options for tile layers, popups, paths -(circles, rectangles, polygons, ...), or other map elements} +\item{options}{tile options} \item{...}{Arguments passed on to \code{\link[leaflet:addProviderTiles]{leaflet::providerTileOptions()}}.} } @@ -43,22 +41,15 @@ layers (e.g. markers and polygons) can share the same group name. See A modified \code{\link[leaflet:leaflet]{leaflet::leaflet()}} \code{map} object. } \description{ -Include tiles of public Spanish organisms to a -\code{\link[leaflet:leaflet]{leaflet::leaflet()}} map. +Include tiles of public Spanish organisms to a \code{\link[leaflet:leaflet]{leaflet::leaflet()}} map. } \details{ -\code{\link[=providerEspTileOptions]{providerEspTileOptions()}} is a wrapper of -\code{\link[leaflet:addProviderTiles]{leaflet::providerTileOptions()}}. +\code{\link[=providerEspTileOptions]{providerEspTileOptions()}} is a wrapper of \code{\link[leaflet:addProviderTiles]{leaflet::providerTileOptions()}}. } \examples{ library(leaflet) -PuertadelSol <- - leaflet() \%>\% - setView( - lat = 40.4166, - lng = -3.7038400, - zoom = 18 - ) \%>\% +PuertadelSol <- leaflet() \%>\% + setView(lat = 40.4166, lng = -3.7038400, zoom = 18) \%>\% addProviderEspTiles(provider = "IGNBase.Gris") \%>\% addProviderEspTiles(provider = "RedTransporte.Carreteras") diff --git a/man/esp_clear_cache.Rd b/man/esp_clear_cache.Rd index 5275fba7..fcf45e51 100644 --- a/man/esp_clear_cache.Rd +++ b/man/esp_clear_cache.Rd @@ -7,11 +7,11 @@ esp_clear_cache(config = FALSE, cached_data = TRUE, verbose = FALSE) } \arguments{ -\item{config}{if \code{TRUE}, will delete the configuration folder of +\item{config}{Logical. If \code{TRUE}, will delete the configuration folder of \CRANpkg{mapSpain}.} -\item{cached_data}{If this is set to \code{TRUE}, it will delete your -\code{cache_dir} and all its content.} +\item{cached_data}{Logical. If \code{TRUE}, it will delete your \code{cache_dir} and +all its content.} \item{verbose}{Logical, displays information. Useful for debugging, default is \code{FALSE}.} diff --git a/man/esp_codelist.Rd b/man/esp_codelist.Rd index 75776925..6ab23e75 100644 --- a/man/esp_codelist.Rd +++ b/man/esp_codelist.Rd @@ -4,9 +4,9 @@ \encoding{UTF-8} \name{esp_codelist} \alias{esp_codelist} -\title{Spanish Code Translation Data Frame} +\title{Database with codes and names of spanish regions} \format{ -A data frame with 59 rows +A \code{\link[base:data.frame]{data.frame}} with 59 rows codes and columns: \describe{ @@ -70,20 +70,20 @@ codes and columns: } } \description{ -A data frame used internally for translating codes and names of the -different subdivisions of Spain. The data frame provides the hierarchy of -the subdivisions including NUTS1 level, Autonomous Communities -(equivalent to NUTS2), Provinces and NUTS3 level. See \strong{Note}. +A \code{data.frame} object used internally for translating codes and names of the +different subdivisions of Spain. The \code{data.frame} provides the hierarchy of +the subdivisions including NUTS1 level, autonomous communities (equivalent +to NUTS2), provinces and NUTS3 level. See \strong{Note}. } \note{ Although NUTS2 matches the first subdivision level of Spain (CCAA - Autonomous Communities), it should be noted that NUTS3 does not match the second subdivision level of Spain (Provinces). NUTS3 provides a -dedicated code for major islands whereas the Provinces doesn't. +dedicated code for major islands whereas the provinces doesn't. Ceuta and Melilla has an specific status (Autonomous Cities) but are -considered as communities with a single province (as Madrid, Asturias -or Murcia) on this dataset. +considered as autonomous communities with a single province (as Madrid, +Asturias or Murcia) on this database. } \examples{ diff --git a/man/esp_detect_cache_dir.Rd b/man/esp_detect_cache_dir.Rd index 5d1e15fd..3ebd249c 100644 --- a/man/esp_detect_cache_dir.Rd +++ b/man/esp_detect_cache_dir.Rd @@ -7,14 +7,14 @@ esp_detect_cache_dir(x = NULL) } \arguments{ -\item{x}{Ignored} +\item{x}{Ignored.} } \value{ A character with the path to your \code{cache_dir}. } \description{ Helper function to detect the current cache folder. See -\code{\link[=esp_set_cache_dir]{esp_set_cache_dir()}} +\code{\link[=esp_set_cache_dir]{esp_set_cache_dir()}}. } \examples{ esp_detect_cache_dir() diff --git a/man/esp_dict.Rd b/man/esp_dict.Rd index b2d1d33b..81c8e84d 100644 --- a/man/esp_dict.Rd +++ b/man/esp_dict.Rd @@ -12,8 +12,8 @@ esp_dict_translate(sourcevar, lang = "en", all = FALSE) \arguments{ \item{sourcevar}{Vector which contains the subdivision names to be converted.} -\item{origin, destination}{One of \code{"text"}, \code{"nuts"}, \code{"iso2"}, -\code{"codauto"} and \code{"cpro"}.} +\item{origin, destination}{One of \code{"text"}, \code{"nuts"}, \code{"iso2"}, \code{"codauto"} +and \code{"cpro"}.} \item{lang}{Language of translation. Available languages are: \itemize{ @@ -30,9 +30,9 @@ On \code{FALSE} it returns a character vector. See \strong{Value}.} \value{ \code{\link[=esp_dict_region_code]{esp_dict_region_code()}} returns a vector of characters. -\code{\link[=esp_dict_translate]{esp_dict_translate()}} returns a character vector or a named -list with each of the possible names of each \code{sourcevar} on the required -language \code{lang}. +\code{\link[=esp_dict_translate]{esp_dict_translate()}} returns a \code{character} vector or a named \code{list} with +each of the possible names of each \code{sourcevar} on the required language +\code{lang}. } \description{ Converts long subdivision names into different coding schemes and languages. diff --git a/man/esp_get_can_box.Rd b/man/esp_get_can_box.Rd index e75f7cef..2b14a006 100644 --- a/man/esp_get_can_box.Rd +++ b/man/esp_get_can_box.Rd @@ -25,14 +25,15 @@ Initial position can be adjusted using the vector of coordinates. See \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} } \value{ -A \code{\link[sf:sf]{sf}} polygon or line depending of \code{style} parameter. +A \code{\link[sf:sf]{sf}} \code{POLYGON} or \code{LINESTRING} depending of \code{style} +parameter. \code{esp_get_can_provinces} returns a \code{LINESTRING} object. } diff --git a/man/esp_get_capimun.Rd b/man/esp_get_capimun.Rd index 3a9142aa..a79e7c64 100644 --- a/man/esp_get_capimun.Rd +++ b/man/esp_get_capimun.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/esp_get_capimun.R \name{esp_get_capimun} \alias{esp_get_capimun} -\title{Get \code{\link[sf:sf]{sf}} points of the municipalities of Spain} +\title{Get \code{\link[sf:sf]{sf}} \code{POINT} of the municipalities of Spain} \source{ IGN data via a custom CDN (see \url{https://github.com/rOpenSpain/mapSpain/tree/sianedata}). @@ -27,10 +27,10 @@ esp_get_capimun( \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{cache}{A logical whether to do caching. Default is \code{TRUE}. See @@ -48,7 +48,7 @@ default is \code{FALSE}.} or \code{NULL} to get all the municipalities. See \strong{Details}.} \item{munic}{A name or \code{\link[base:grep]{regex}} expression with the names of -the required municipalities. \code{NULL} would not produce any filtering.} +the required municipalities. \code{NULL} would return all municipalities.} \item{moveCAN}{A logical \code{TRUE/FALSE} or a vector of coordinates \code{c(lat, lon)}. It places the Canary Islands close to Spain's mainland. @@ -56,13 +56,13 @@ Initial position can be adjusted using the vector of coordinates. See \strong{Displacing the Canary Islands}.} \item{rawcols}{Logical. Setting this to \code{TRUE} would add the raw columns of -the dataset provided by IGN.} +the resulting object as provided by IGN.} } \value{ -A \code{\link[sf:sf]{sf}} point object. +A \code{\link[sf:sf]{sf}} \code{POINT} object. } \description{ -Get a \code{\link[sf:sf]{sf}} point with the location of the political powers for +Get a \code{\link[sf:sf]{sf}} \code{POINT} with the location of the political powers for each municipality (possibly the center of the municipality). Note that this differs of the centroid of the boundaries of the @@ -77,8 +77,8 @@ When using \code{region} you can use and mix names and NUTS codes (levels 1, 2 or 3), ISO codes (corresponding to level 2 or 3) or \code{cpro}. See \link{esp_codelist} -When calling a superior level (Province, Autonomous Community or NUTS1) , -all the municipalities of that level would be added. +When calling a higher level (province, CCAA or NUTS1), all the municipalities +of that level would be added. } \section{About caching}{ You can set your \code{cache_dir} with \code{\link[=esp_set_cache_dir]{esp_set_cache_dir()}}. diff --git a/man/esp_get_ccaa.Rd b/man/esp_get_ccaa.Rd index adb704c0..98acf2e1 100644 --- a/man/esp_get_ccaa.Rd +++ b/man/esp_get_ccaa.Rd @@ -3,7 +3,7 @@ \name{esp_get_ccaa} \alias{esp_get_ccaa} \alias{esp_get_ccaa_siane} -\title{Get Autonomous Communities of Spain as \code{\link[sf:sf]{sf}} polygons and points} +\title{Get Autonomous Communities of Spain as \code{\link[sf:sf]{sf}} \code{POLYGON} or \code{POINT}} \source{ IGN data via a custom CDN (see \url{https://github.com/rOpenSpain/mapSpain/tree/sianedata}). @@ -38,21 +38,21 @@ Initial position can be adjusted using the vector of coordinates. See \describe{ \item{\code{spatialtype}}{Type of geometry to be returned: \itemize{ -\item \code{"LB"}: Labels - point object. -\item \code{"RG"}: Regions - polygon object. +\item \code{"LB"}: Labels - \code{POINT} object. +\item \code{"RG"}: Regions - \code{POLYGON} object. }} }} \item{year}{Release year. See \code{\link[=esp_get_nuts]{esp_get_nuts()}} for \code{\link[=esp_get_ccaa]{esp_get_ccaa()}} and -\strong{Details} for \code{\link[=esp_get_ccaa_siane]{esp_get_ccaa_siane()}}} +\strong{Details} for \code{\link[=esp_get_ccaa_siane]{esp_get_ccaa_siane()}}.} \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{cache}{A logical whether to do caching. Default is \code{TRUE}. See @@ -66,11 +66,11 @@ When set to \code{TRUE} it would force a fresh download of the source file.} \item{verbose}{Logical, displays information. Useful for debugging, default is \code{FALSE}.} -\item{resolution}{Resolution of the polygon. Values available are +\item{resolution}{Resolution of the \code{POLYGON}. Values available are \code{3}, \code{6.5} or \code{10}.} \item{rawcols}{Logical. Setting this to \code{TRUE} would add the raw columns of -the dataset provided by IGN.} +the resulting object as provided by IGN.} } \value{ A \code{\link[sf:sf]{sf}} object specified by \code{spatialtype}. @@ -78,7 +78,7 @@ A \code{\link[sf:sf]{sf}} object specified by \code{spatialtype}. \description{ Returns \href{https://en.wikipedia.org/wiki/Autonomous_communities_of_Spain}{Autonomous Communities of Spain} as -polygons and points at a specified scale. +\code{sf} \code{POLYGON} or \code{POINT} at a specified scale. \itemize{ \item \code{\link[=esp_get_ccaa]{esp_get_ccaa()}} uses GISCO (Eurostat) as source. Please use \code{\link[giscoR:gisco_attributions]{giscoR::gisco_attributions()}} diff --git a/man/esp_get_comarca.Rd b/man/esp_get_comarca.Rd index 77b1f38b..843de937 100644 --- a/man/esp_get_comarca.Rd +++ b/man/esp_get_comarca.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/esp_get_comarca.R \name{esp_get_comarca} \alias{esp_get_comarca} -\title{Get 'comarcas' of Spain as \code{\link[sf:sf]{sf}} polygons} +\title{Get 'comarcas' of Spain as \code{\link[sf:sf]{sf}} \code{POLYGON}} \source{ INE: PC_Axis files. } @@ -19,10 +19,10 @@ esp_get_comarca( } \arguments{ \item{region}{A vector of names and/or codes for provinces or \code{NULL} to get -all the comarcas., See \strong{Details}.} +all the comarcas. See \strong{Details}.} \item{comarca}{A name or \code{\link[base:grep]{regex}} expression with the names of -the required comarcas. \code{NULL} would not produce any filtering.} +the required comarcas. \code{NULL} would return all the possible comarcas.} \item{moveCAN}{A logical \code{TRUE/FALSE} or a vector of coordinates \code{c(lat, lon)}. It places the Canary Islands close to Spain's mainland. @@ -32,10 +32,10 @@ Initial position can be adjusted using the vector of coordinates. See \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{update_cache}{A logical whether to update cache. Default is \code{FALSE}. @@ -50,7 +50,7 @@ default is \code{FALSE}.} A \code{\link[sf:sf]{sf}} polygon object. } \description{ -Returns 'comarcas' of Spain as polygons,as provided by the +Returns 'comarcas' of Spain as \code{sf} \code{POLYGON} objects, as provided by the \strong{INE} (Instituto Nacional de Estadistica). } \details{ @@ -63,7 +63,7 @@ When using \code{region} you can use and mix names and NUTS codes (levels 1, 2 or 3), ISO codes (corresponding to level 2 or 3) or "cpro" (see \link{esp_codelist}). -When calling a superior level (Province, Autonomous Community or NUTS1) , +When calling a higher level (Province, Autonomous Community or NUTS1), all the comarcas of that level would be added. \subsection{Legal Notice}{ diff --git a/man/esp_get_country.Rd b/man/esp_get_country.Rd index 9884889f..456168a7 100644 --- a/man/esp_get_country.Rd +++ b/man/esp_get_country.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/esp_get_country.R \name{esp_get_country} \alias{esp_get_country} -\title{Get the borders of Spain as a \code{\link[sf:sf]{sf}} polygon} +\title{Get \code{\link[sf:sf]{sf}} \code{POLYGON} representing Spain} \usage{ esp_get_country(moveCAN = TRUE, ...) } @@ -20,10 +20,10 @@ Initial position can be adjusted using the vector of coordinates. See \item{\code{epsg}}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{\code{cache}}{A logical whether to do caching. Default is \code{TRUE}. See \strong{About caching}.} @@ -34,19 +34,19 @@ When set to \code{TRUE} it would force a fresh download of the source file.} default is \code{FALSE}.} \item{\code{resolution}}{Resolution of the geospatial data. One of \itemize{ -\item "60": 1:60million -\item "20": 1:20million -\item "10": 1:10million -\item "03": 1:3million -\item "01": 1:1million +\item \code{"60"}: 1:60million +\item \code{"20"}: 1:20million +\item \code{"10"}: 1:10million +\item \code{"03"}: 1:3million +\item \code{"01"}: 1:1million }} }} } \value{ -A \code{\link[sf:sf]{sf}} polygon object. +A \code{\link[sf:sf]{sf}} \code{POLYGON} object. } \description{ -Returns the boundaries of Spain as a single \code{\link[sf:sf]{sf}} polygon at a +Returns the boundaries of Spain as a single \code{\link[sf:sf]{sf}} \code{POLYGON} at a specified scale. } \section{About caching}{ diff --git a/man/esp_get_grid_BDN.Rd b/man/esp_get_grid_BDN.Rd index 40ce3f09..5f045d9a 100644 --- a/man/esp_get_grid_BDN.Rd +++ b/man/esp_get_grid_BDN.Rd @@ -3,7 +3,7 @@ \name{esp_get_grid_BDN} \alias{esp_get_grid_BDN} \alias{esp_get_grid_BDN_ccaa} -\title{Get \code{\link[sf:sf]{sf}} polygons with the national geographic grids from BDN} +\title{Get \code{\link[sf:sf]{sf}} \code{POLYGON} with the national geographic grids from BDN} \source{ BDN data via a custom CDN (see \url{https://github.com/rOpenSpain/mapSpain/tree/sianedata/MTN}). @@ -45,10 +45,10 @@ default is \code{FALSE}.} See \strong{Details} on \code{\link[=esp_get_ccaa]{esp_get_ccaa()}}.} } \value{ -A \code{\link[sf:sf]{sf}} polygon +A \code{\link[sf:sf]{sf}} \code{POLYGON}. } \description{ -Loads a \code{\link[sf:sf]{sf}} polygon with the geographic grids of Spain as +Loads a \code{\link[sf:sf]{sf}} \code{POLYGON} with the geographic grids of Spain as provided on the Banco de Datos de la Naturaleza (Nature Data Bank), by the Ministry of Environment (MITECO): \itemize{ diff --git a/man/esp_get_grid_EEA.Rd b/man/esp_get_grid_EEA.Rd index 1171f5a6..06910bb0 100644 --- a/man/esp_get_grid_EEA.Rd +++ b/man/esp_get_grid_EEA.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/esp_get_grid_EEA.R \name{esp_get_grid_EEA} \alias{esp_get_grid_EEA} -\title{Get \code{\link[sf:sf]{sf}} polygons of the national geographic grids from EEA} +\title{Get \code{\link[sf:sf]{sf}} \code{POLYGON} of the national geographic grids from EEA} \source{ \href{https://www.eea.europa.eu/en/datahub/datahubitem-view/3c362237-daa4-45e2-8c16-aaadfb1a003b}{EEA reference grid}. } @@ -30,10 +30,10 @@ When set to \code{TRUE} it would force a fresh download of the source file.} default is \code{FALSE}.} } \value{ -A \code{\link[sf:sf]{sf}} polygon +A \code{\link[sf:sf]{sf}} \code{POLYGON}. } \description{ -Loads a \code{\link[sf:sf]{sf}} polygon with the geographic grids of Spain as +Loads a \code{\link[sf:sf]{sf}} \code{POLYGON} with the geographic grids of Spain as provided by the European Environment Agency (EEA). } \section{About caching}{ diff --git a/man/esp_get_grid_ESDAC.Rd b/man/esp_get_grid_ESDAC.Rd index e2e61447..98ae0700 100644 --- a/man/esp_get_grid_ESDAC.Rd +++ b/man/esp_get_grid_ESDAC.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/esp_get_grid_ESDAC.R \name{esp_get_grid_ESDAC} \alias{esp_get_grid_ESDAC} -\title{Get \code{\link[sf:sf]{sf}} polygons of the national geographic grids from ESDAC} +\title{Get \code{\link[sf:sf]{sf}} \code{POLYGON} of the national geographic grids from ESDAC} \source{ \href{https://esdac.jrc.ec.europa.eu/content/european-reference-grids}{EEA reference grid}. } @@ -26,10 +26,10 @@ When set to \code{TRUE} it would force a fresh download of the source file.} default is \code{FALSE}.} } \value{ -A \code{\link[sf:sf]{sf}} polygon +A \code{\link[sf:sf]{sf}} \code{POLYGON}. } \description{ -Loads a \code{\link[sf:sf]{sf}} polygon with the geographic grids of Spain as +Loads a \code{\link[sf:sf]{sf}} \code{POLYGON} with the geographic grids of Spain as provided by the European Soil Data Centre (ESDAC). } \section{About caching}{ diff --git a/man/esp_get_grid_MTN.Rd b/man/esp_get_grid_MTN.Rd index 1da6cb27..9671e8dc 100644 --- a/man/esp_get_grid_MTN.Rd +++ b/man/esp_get_grid_MTN.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/esp_get_grid_MTN.R \name{esp_get_grid_MTN} \alias{esp_get_grid_MTN} -\title{Get \code{\link[sf:sf]{sf}} polygons of the national geographic grids from IGN} +\title{Get \code{\link[sf:sf]{sf}} \code{POLYGON} of the national geographic grids from IGN} \source{ IGN data via a custom CDN (see \url{https://github.com/rOpenSpain/mapSpain/tree/sianedata/MTN}). @@ -27,10 +27,10 @@ When set to \code{TRUE} it would force a fresh download of the source file.} default is \code{FALSE}.} } \value{ -A \code{\link[sf:sf]{sf}} polygon +A \code{\link[sf:sf]{sf}} \code{POLYGON}. } \description{ -Loads a \code{\link[sf:sf]{sf}} polygon with the geographic grids of Spain. +Loads a \code{\link[sf:sf]{sf}} \code{POLYGON} with the geographic grids of Spain. } \details{ Metadata available on diff --git a/man/esp_get_gridmap.Rd b/man/esp_get_gridmap.Rd index 80b020a5..ad740d52 100644 --- a/man/esp_get_gridmap.Rd +++ b/man/esp_get_gridmap.Rd @@ -6,7 +6,7 @@ \alias{esp_get_hex_ccaa} \alias{esp_get_grid_prov} \alias{esp_get_grid_ccaa} -\title{Get a \code{\link[sf:sf]{sf}} hexbin or squared polygon of Spain} +\title{Get a \code{\link[sf:sf]{sf}} hexbin or squared \code{POLYGON} of Spain} \usage{ esp_get_hex_prov(prov = NULL) @@ -17,14 +17,14 @@ esp_get_grid_prov(prov = NULL) esp_get_grid_ccaa(ccaa = NULL) } \arguments{ -\item{prov}{A vector of names and/or codes for provinces -or \code{NULL} to get all the provinces. See \strong{Details}.} +\item{prov}{A vector of names and/or codes for provinces or \code{NULL} to get all +the provinces. See \strong{Details}.} \item{ccaa}{A vector of names and/or codes for autonomous communities or \code{NULL} to get all the autonomous communities. See \strong{Details}.} } \value{ -A \code{\link[sf:sf]{sf}} POLYGON object. +A \code{\link[sf:sf]{sf}} \code{POLYGON} object. } \description{ Loads a hexbin map (\code{\link[sf:sf]{sf}} object) or a map of squares with the @@ -36,12 +36,12 @@ In choropleths, a large polygon data looks more emphasized just because of its size, what introduces a bias. Here with hexbin, each region is represented equally dismissing the bias. -You can use and mix names, ISO codes, "codauto"/"cpro" codes (see +You can use and mix names, ISO codes, \code{"codauto"/ "cpro"} codes (see \link{esp_codelist}) and NUTS codes of different levels. When using a code corresponding of a higher level (e.g. \code{esp_get_prov("Andalucia")}) all the corresponding units of that level are -provided (in this case , all the provinces of Andalucia). +provided (in this case , all the provinces of Andalusia). Results are provided in \strong{EPSG:4258}, use \code{\link[sf:st_transform]{sf::st_transform()}} to change the projection. diff --git a/man/esp_get_hydrobasin.Rd b/man/esp_get_hydrobasin.Rd index b9f5c135..da4d7db6 100644 --- a/man/esp_get_hydrobasin.Rd +++ b/man/esp_get_hydrobasin.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/esp_get_hydrobasin.R \name{esp_get_hydrobasin} \alias{esp_get_hydrobasin} -\title{Get \code{\link[sf:sf]{sf}} polygons of the drainage basin demarcations of Spain} +\title{Get \code{\link[sf:sf]{sf}} \code{POLYGON} of the drainage basin demarcations of Spain} \source{ IGN data via a custom CDN (see \url{https://github.com/rOpenSpain/mapSpain/tree/sianedata}). @@ -22,10 +22,10 @@ esp_get_hydrobasin( \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{cache}{A logical whether to do caching. Default is \code{TRUE}. See @@ -39,18 +39,18 @@ When set to \code{TRUE} it would force a fresh download of the source file.} \item{verbose}{Logical, displays information. Useful for debugging, default is \code{FALSE}.} -\item{resolution}{Resolution of the polygon. Values available are +\item{resolution}{Resolution of the \code{POLYGON}. Values available are \code{"3"}, \code{"6.5"} or \code{"10"}.} \item{domain}{Possible values are \code{"land"}, that includes only the ground part or the ground or \code{"landsea"}, that includes both the ground -and the related sea waters of the basin} +and the related sea waters of the basin.} } \value{ -A \code{\link[sf:sf]{sf}} polygon object. +A \code{\link[sf:sf]{sf}} \code{POLYGON} object. } \description{ -Loads a \code{\link[sf:sf]{sf}} polygon object containing areas with the required +Loads a \code{\link[sf:sf]{sf}} \code{POLYGON} object containing areas with the required hydrographic elements of Spain. } \details{ diff --git a/man/esp_get_hypsobath.Rd b/man/esp_get_hypsobath.Rd index e7d838f0..24de54d8 100644 --- a/man/esp_get_hypsobath.Rd +++ b/man/esp_get_hypsobath.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/esp_get_hypsobath.R \name{esp_get_hypsobath} \alias{esp_get_hypsobath} -\title{Get \code{\link[sf:sf]{sf}} polygons and lines with hypsometry and bathymetry of -Spain.} +\title{Get \code{\link[sf:sf]{sf}} \code{POLYGON} or \code{LINESTRING} with hypsometry and +bathymetry of Spain} \source{ IGN data via a custom CDN (see \url{https://github.com/rOpenSpain/mapSpain/tree/sianedata}). @@ -23,10 +23,10 @@ esp_get_hypsobath( \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{cache}{A logical whether to do caching. Default is \code{TRUE}. See @@ -43,15 +43,15 @@ default is \code{FALSE}.} \item{resolution}{Resolution of the shape. Values available are \code{"3"} or \code{"6.5"}.} -\item{spatialtype}{Spatial type of the output. Use \code{"area"} for polygons or -\code{"line"} for lines.} +\item{spatialtype}{Spatial type of the output. Use \code{"area"} for \code{POLYGON} or +\code{"line"} for \code{LINESTRING}.} } \value{ -A \code{\link[sf:sf]{sf}} polygon or line object. +A \code{\link[sf:sf]{sf}} \code{POLYGON} or \code{LINESTRING} object. } \description{ -Loads a \code{\link[sf:sf]{sf}} polygon or line object representing the hypsometry -and bathymetry of Spain. +Loads a \code{\link[sf:sf]{sf}} \code{POLYGON} or \code{LINESTRING} object representing the +hypsometry and bathymetry of Spain. \itemize{ \item \strong{Hypsometry} represents the the elevation and depth of features of the Earth's surface relative to mean sea level. @@ -88,7 +88,8 @@ hypsobath <- esp_get_hypsobath() hypsobath <- hypsobath[!sf::st_is_empty(hypsobath), ] # Tints from Wikipedia -# https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Maps/Conventions/Topographic_maps +# https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Maps/Conventions/ +# Topographic_maps bath_tints <- colorRampPalette( rev( diff --git a/man/esp_get_munic.Rd b/man/esp_get_munic.Rd index eb74d2b5..e15fb7e0 100644 --- a/man/esp_get_munic.Rd +++ b/man/esp_get_munic.Rd @@ -3,7 +3,7 @@ \name{esp_get_munic} \alias{esp_get_munic} \alias{esp_get_munic_siane} -\title{Get municipalities of Spain as \code{\link[sf:sf]{sf}} polygons} +\title{Get municipalities of Spain as \code{\link[sf:sf]{sf}} \code{POLYGON}} \source{ \href{https://gisco-services.ec.europa.eu/distribution/v2/}{GISCO API} @@ -43,10 +43,10 @@ esp_get_munic_siane( \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{cache}{A logical whether to do caching. Default is \code{TRUE}. See @@ -64,7 +64,7 @@ default is \code{FALSE}.} or \code{NULL} to get all the municipalities. See \strong{Details}.} \item{munic}{A name or \code{\link[base:grep]{regex}} expression with the names of -the required municipalities. \code{NULL} would not produce any filtering.} +the required municipalities. \code{NULL} would return all municipalities.} \item{moveCAN}{A logical \code{TRUE/FALSE} or a vector of coordinates \code{c(lat, lon)}. It places the Canary Islands close to Spain's mainland. @@ -75,16 +75,16 @@ Initial position can be adjusted using the vector of coordinates. See \code{"3"}, \code{"6.5"} or \code{"10"}.} \item{rawcols}{Logical. Setting this to \code{TRUE} would add the raw columns of -the dataset provided by IGN.} +the resulting object as provided by IGN.} } \value{ -A \code{\link[sf:sf]{sf}} polygon +A \code{\link[sf:sf]{sf}} \code{POLYGON}. } \description{ -Returns municipalities of Spain as polygons at a specified scale. +Returns municipalities of Spain \code{sf} POLYGON` at a specified scale. \itemize{ \item \code{\link[=esp_get_munic]{esp_get_munic()}} uses GISCO (Eurostat) as source. Please use -\code{\link[giscoR:gisco_attributions]{giscoR::gisco_attributions()}} +\code{\link[giscoR:gisco_attributions]{giscoR::gisco_attributions()}}. } \itemize{ @@ -104,12 +104,12 @@ format, as end of year) or as a specific date ("YYYY-MM-DD" format). Historical information starts as of 2005. } -When using \code{region} you can use and mix names and NUTS codes -(levels 1, 2 or 3), ISO codes (corresponding to level 2 or 3) or -"cpro" (see \link{esp_codelist}). +When using \code{region} you can use and mix names and NUTS codes (levels 1, 2 or +3), ISO codes (corresponding to level 2 or 3) or \code{"cpro"} +(see \link{esp_codelist}). -When calling a superior level (Province, Autonomous Community or NUTS1) , -all the municipalities of that level would be added. +When calling a higher level (Province, Autonomous Community or NUTS1), all +the municipalities of that level would be added. } \section{About caching}{ You can set your \code{cache_dir} with \code{\link[=esp_set_cache_dir]{esp_set_cache_dir()}}. diff --git a/man/esp_get_nuts.Rd b/man/esp_get_nuts.Rd index f3c107b1..bc72153a 100644 --- a/man/esp_get_nuts.Rd +++ b/man/esp_get_nuts.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/esp_get_nuts.R \name{esp_get_nuts} \alias{esp_get_nuts} -\title{Get NUTS of Spain as \code{\link[sf:sf]{sf}} polygons and points} +\title{Get NUTS of Spain as \code{\link[sf:sf]{sf}} \code{POLYGON} or \code{POINT}} \source{ \href{https://gisco-services.ec.europa.eu/distribution/v2/}{GISCO API} } @@ -28,10 +28,10 @@ esp_get_nuts( \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{cache}{A logical whether to do caching. Default is \code{TRUE}. See @@ -47,24 +47,24 @@ default is \code{FALSE}.} \item{resolution}{Resolution of the geospatial data. One of \itemize{ -\item "60": 1:60million -\item "20": 1:20million -\item "10": 1:10million -\item "03": 1:3million -\item "01": 1:1million +\item \code{"60"}: 1:60million +\item \code{"20"}: 1:20million +\item \code{"10"}: 1:10million +\item \code{"03"}: 1:3million +\item \code{"01"}: 1:1million }} \item{spatialtype}{Type of geometry to be returned: \itemize{ -\item \code{"LB"}: Labels - point object. -\item \code{"RG"}: Regions - polygon object. +\item \code{"LB"}: Labels - \code{POINT} object. +\item \code{"RG"}: Regions - \code{POLYGON} object. }} \item{region}{Optional. A vector of region names, NUTS or ISO codes (see \code{\link[=esp_dict_region_code]{esp_dict_region_code()}}).} -\item{nuts_level}{NUTS level. One of "0" (Country-level), "1", "2" or "3". -See \strong{Description}.} +\item{nuts_level}{NUTS level. One of \code{"0"} (Country-level), \code{"1"}, \code{"2"} or +\code{"3"}. See \strong{Description}.} \item{moveCAN}{A logical \code{TRUE/FALSE} or a vector of coordinates \code{c(lat, lon)}. It places the Canary Islands close to Spain's mainland. @@ -76,17 +76,17 @@ A \code{\link[sf:sf]{sf}} object specified by \code{spatialtype}. } \description{ Returns \href{https://en.wikipedia.org/wiki/NUTS_statistical_regions_of_Spain}{NUTS regions of Spain} -as polygons and points at a specified scale, as provided by +as \code{POLYGON} or \code{POINT} at a specified scale, as provided by \href{https://ec.europa.eu/eurostat/web/gisco}{GISCO} (Geographic Information System of the Commission, depending of Eurostat). NUTS are provided at three different levels: \itemize{ -\item \strong{"0"}: Country level -\item \strong{"1"}: Groups of autonomous communities -\item \strong{"2"}: Autonomous communities +\item \strong{"0"}: Country level. +\item \strong{"1"}: Groups of autonomous communities. +\item \strong{"2"}: Autonomous communities (CCAA). \item \strong{"3"}: Roughly matches the provinces, but providing specific individual -objects for each major island +objects for each major island. } } \note{ @@ -150,8 +150,10 @@ ggplot(NUTS1_orig) + ) -AndOriental <- - esp_get_nuts(region = c("Almeria", "Granada", "Jaen", "Malaga")) +AndOriental <- esp_get_nuts(region = c( + "Almeria", "Granada", + "Jaen", "Malaga" +)) ggplot(AndOriental) + diff --git a/man/esp_get_prov.Rd b/man/esp_get_prov.Rd index 8e33e37e..cd549aa8 100644 --- a/man/esp_get_prov.Rd +++ b/man/esp_get_prov.Rd @@ -3,7 +3,7 @@ \name{esp_get_prov} \alias{esp_get_prov} \alias{esp_get_prov_siane} -\title{Get Provinces of Spain as \code{\link[sf:sf]{sf}} polygons and points} +\title{Get Provinces of Spain as \code{\link[sf:sf]{sf}} \code{POLYGON} or \code{POINT}} \source{ IGN data via a custom CDN (see \url{https://github.com/rOpenSpain/mapSpain/tree/sianedata}). @@ -25,8 +25,8 @@ esp_get_prov_siane( ) } \arguments{ -\item{prov}{A vector of names and/or codes for provinces -or \code{NULL} to get all the provinces. See \strong{Details}.} +\item{prov}{A vector of names and/or codes for provinces or \code{NULL} to get all +the provinces. See \strong{Details}.} \item{moveCAN}{A logical \code{TRUE/FALSE} or a vector of coordinates \code{c(lat, lon)}. It places the Canary Islands close to Spain's mainland. @@ -38,21 +38,21 @@ Initial position can be adjusted using the vector of coordinates. See \describe{ \item{\code{spatialtype}}{Type of geometry to be returned: \itemize{ -\item \code{"LB"}: Labels - point object. -\item \code{"RG"}: Regions - polygon object. +\item \code{"LB"}: Labels - \code{POINT} object. +\item \code{"RG"}: Regions - \code{POLYGON} object. }} }} \item{year}{Release year. See \code{\link[=esp_get_nuts]{esp_get_nuts()}} for \code{\link[=esp_get_prov]{esp_get_prov()}} and -\strong{Details} for \code{\link[=esp_get_prov_siane]{esp_get_prov_siane()}}} +\strong{Details} for \code{\link[=esp_get_prov_siane]{esp_get_prov_siane()}}.} \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{cache}{A logical whether to do caching. Default is \code{TRUE}. See @@ -66,11 +66,11 @@ When set to \code{TRUE} it would force a fresh download of the source file.} \item{verbose}{Logical, displays information. Useful for debugging, default is \code{FALSE}.} -\item{resolution}{Resolution of the polygon. Values available are +\item{resolution}{Resolution of the \code{POLYGON}. Values available are \code{3}, \code{6.5} or \code{10}.} \item{rawcols}{Logical. Setting this to \code{TRUE} would add the raw columns of -the dataset provided by IGN.} +the resulting object as provided by IGN.} } \value{ A \code{\link[sf:sf]{sf}} object specified by \code{spatialtype}. @@ -78,7 +78,7 @@ A \code{\link[sf:sf]{sf}} object specified by \code{spatialtype}. \description{ Returns \href{https://en.wikipedia.org/wiki/Provinces_of_Spain}{provinces of Spain} -as polygons and points at a specified scale. +as \code{POLYGON} or \code{POINT} at a specified scale. \itemize{ \item \code{\link[=esp_get_prov]{esp_get_prov()}} uses GISCO (Eurostat) as source. Please use \code{\link[giscoR:gisco_attributions]{giscoR::gisco_attributions()}} @@ -97,8 +97,8 @@ When using \code{prov} you can use and mix names and NUTS codes (levels 1, 2 or Ceuta and Melilla are considered as provinces on this dataset. -When calling a superior level (Autonomous Community or NUTS1) , -all the provinces of that level would be added. +When calling a higher level (Autonomous Community or NUTS1), all the +provinces of that level would be added. On \code{\link[=esp_get_prov_siane]{esp_get_prov_siane()}}, \code{year} could be passed as a single year ("YYYY" format, as end of year) or as a specific date ("YYYY-MM-DD" format). @@ -136,14 +136,10 @@ ggplot(prov) + \donttest{ # Random Provinces -Random <- - esp_get_prov(prov = c( - "Zamora", - "Palencia", - "ES-GR", - "ES521", - "01" - )) +Random <- esp_get_prov(prov = c( + "Zamora", "Palencia", "ES-GR", + "ES521", "01" +)) ggplot(Random) + diff --git a/man/esp_get_railway.Rd b/man/esp_get_railway.Rd index 05571306..1fab0b9d 100644 --- a/man/esp_get_railway.Rd +++ b/man/esp_get_railway.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/esp_get_railway.R \name{esp_get_railway} \alias{esp_get_railway} -\title{Get \code{\link[sf:sf]{sf}} lines and points with the railways of Spain} +\title{Get \code{\link[sf:sf]{sf}} \code{LINESTRING} or \code{POINT} with the railways of Spain} \source{ IGN data via a custom CDN (see \url{https://github.com/rOpenSpain/mapSpain/tree/sianedata}). @@ -24,10 +24,10 @@ esp_get_railway( \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{cache}{A logical whether to do caching. Default is \code{TRUE}. See @@ -46,11 +46,11 @@ for extracting the railway as lines and \code{"point"} for extracting stations.} } \value{ -A \code{\link[sf:sf]{sf}} line or point object. +A \code{\link[sf:sf]{sf}} \code{LINESTRING} or \code{POINT} object. } \description{ -Loads a \code{\link[sf:sf]{sf}} lines or point object representing the nodes and -railway lines of Spain. +Loads a \code{\link[sf:sf]{sf}} \code{LINESTRING} or \code{POINT} object representing the +nodes and railway lines of Spain. } \section{About caching}{ You can set your \code{cache_dir} with \code{\link[=esp_set_cache_dir]{esp_set_cache_dir()}}. diff --git a/man/esp_get_rivers.Rd b/man/esp_get_rivers.Rd index 92e018be..9e7d6fe2 100644 --- a/man/esp_get_rivers.Rd +++ b/man/esp_get_rivers.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/esp_get_rivers.R \name{esp_get_rivers} \alias{esp_get_rivers} -\title{Get \code{\link[sf:sf]{sf}} polygon and lines of rivers, channels and other +\title{Get \code{\link[sf:sf]{sf}} \code{POLYGON} or \code{LINESTRING} of rivers, channels and other wetlands of Spain} \source{ IGN data via a custom CDN (see @@ -24,10 +24,10 @@ esp_get_rivers( \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{cache}{A logical whether to do caching. Default is \code{TRUE}. See @@ -41,21 +41,21 @@ When set to \code{TRUE} it would force a fresh download of the source file.} \item{verbose}{Logical, displays information. Useful for debugging, default is \code{FALSE}.} -\item{resolution}{Resolution of the polygon. Values available are +\item{resolution}{Resolution of the \code{POLYGON}. Values available are \code{"3"}, \code{"6.5"} or \code{"10"}.} -\item{spatialtype}{Spatial type of the output. Use \code{"area"} for polygons or -\code{"line"} for lines.} +\item{spatialtype}{Spatial type of the output. Use \code{"area"} for \code{POLYGON} or +\code{"line"} for \code{LINESTRING}.} \item{name}{Optional. A character or \code{\link[base:grep]{regex}} expression with the name of the element(s) to be extracted.} } \value{ -A \code{\link[sf:sf]{sf}} polygon or line object. +A \code{\link[sf:sf]{sf}} \code{POLYGON} or \code{LINESTRING} object. } \description{ -Loads a \code{\link[sf:sf]{sf}} polygon or line object representing rivers, -channels, reservoirs and other wetlands of Spain. +Loads a \code{\link[sf:sf]{sf}} \code{POLYGON} or \code{LINESTRING} object representing +rivers, channels, reservoirs and other wetlands of Spain. } \details{ Metadata available on diff --git a/man/esp_get_roads.Rd b/man/esp_get_roads.Rd index c8a950dc..dd5f87b2 100644 --- a/man/esp_get_roads.Rd +++ b/man/esp_get_roads.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/esp_get_roads.R \name{esp_get_roads} \alias{esp_get_roads} -\title{Get \code{\link[sf:sf]{sf}} lines of the roads of Spain} +\title{Get \code{\link[sf:sf]{sf}} \code{LINESTRING} of the roads of Spain} \source{ IGN data via a custom CDN (see \url{https://github.com/rOpenSpain/mapSpain/tree/sianedata}). @@ -24,10 +24,10 @@ esp_get_roads( \item{epsg}{projection of the map: 4-digit \href{https://epsg.io/}{EPSG code}. One of: \itemize{ -\item \code{"4258"}: ETRS89 -\item \code{"4326"}: WGS84 -\item \code{"3035"}: ETRS89 / ETRS-LAEA -\item \code{"3857"}: Pseudo-Mercator +\item \code{"4258"}: ETRS89. +\item \code{"4326"}: WGS84. +\item \code{"3035"}: ETRS89 / ETRS-LAEA. +\item \code{"3857"}: Pseudo-Mercator. }} \item{cache}{A logical whether to do caching. Default is \code{TRUE}. See @@ -47,10 +47,11 @@ Initial position can be adjusted using the vector of coordinates. See \strong{Displacing the Canary Islands}.} } \value{ -A \code{\link[sf:sf]{sf}} line object. +A \code{\link[sf:sf]{sf}} \code{LINESTRING} object. } \description{ -Loads a \code{\link[sf:sf]{sf}} line object representing the main roads of Spain. +Loads a \code{\link[sf:sf]{sf}} \code{LINESTRING} object representing the main roads of +Spain. } \details{ \code{year} could be passed as a single year ("YYYY" format, as end of year) or diff --git a/man/esp_get_simplified.Rd b/man/esp_get_simplified.Rd index 49ab7fce..af1cc9cc 100644 --- a/man/esp_get_simplified.Rd +++ b/man/esp_get_simplified.Rd @@ -23,8 +23,8 @@ esp_get_simpl_ccaa( ) } \arguments{ -\item{prov}{A vector of names and/or codes for provinces -or \code{NULL} to get all the provinces. See \strong{Details}.} +\item{prov}{A vector of names and/or codes for provinces or \code{NULL} to get all +the provinces. See \strong{Details}.} \item{update_cache}{A logical whether to update cache. Default is \code{FALSE}. When set to \code{TRUE} it would force a fresh download of the source file.} @@ -38,7 +38,7 @@ default is \code{FALSE}.} or \code{NULL} to get all the autonomous communities. See \strong{Details}.} } \value{ -A \code{\link[sf:sf]{sf}} POLYGON object. +A \code{\link[sf:sf]{sf}} \code{POLYGON} object. } \description{ Loads a simplified map (\code{\link[sf:sf]{sf}} object) with the boundaries of the @@ -48,12 +48,12 @@ provinces or autonomous communities of Spain, as provided by the \strong{INE} \details{ Results are provided \strong{without CRS}, as provided on source. -You can use and mix names, ISO codes, "codauto"/"cpro" codes (see +You can use and mix names, ISO codes, \code{"codauto"/"cpro"} codes (see \link{esp_codelist}) and NUTS codes of different levels. When using a code corresponding of a higher level (e.g. \code{esp_get_simpl_prov("Andalucia")}) all the corresponding units of that level -are provided (in this case , all the provinces of Andalucia). +are provided (in this case , all the provinces of Andalusia). } \section{About caching}{ You can set your \code{cache_dir} with \code{\link[=esp_set_cache_dir]{esp_set_cache_dir()}}. diff --git a/man/esp_make_provider.Rd b/man/esp_make_provider.Rd index 75b5cf57..f19ddcb1 100644 --- a/man/esp_make_provider.Rd +++ b/man/esp_make_provider.Rd @@ -10,11 +10,11 @@ esp_make_provider(id, q, service, layers, ...) \item{id}{An identifier for the user. Would be used also for identifying cached tiles.} -\item{q}{The base url of the service} +\item{q}{The base url of the service.} \item{service}{The type of tile service, either \code{"WMS"} or \code{"WMTS"}.} -\item{layers}{The name of the layer to retrieve} +\item{layers}{The name of the layer to retrieve.} \item{...}{Additional parameters to the query, like \code{version}, \code{format}, \code{crs/srs}, \code{style}, ... depending on the capabilities of the service.} @@ -46,6 +46,7 @@ custom_wms <- esp_make_provider( id = "an_id_for_caching", q = "https://idecyl.jcyl.es/geoserver/ge/wms?", service = "WMS", + version = "1.3.0", layers = "geolog_cyl_litologia" ) diff --git a/man/esp_munic.sf.Rd b/man/esp_munic.sf.Rd index e090b35d..66916e69 100644 --- a/man/esp_munic.sf.Rd +++ b/man/esp_munic.sf.Rd @@ -4,9 +4,9 @@ \encoding{UTF-8} \name{esp_munic.sf} \alias{esp_munic.sf} -\title{All Municipalities \code{POLYGON} object of Spain (2019)} +\title{\code{\link[sf:sf]{sf}} object with all the municipalities of Spain (2019)} \format{ -A \code{\link[sf:sf]{sf}} object (resolution: 1:1million, EPSG:4258) object with +A \code{\link[sf:sf]{sf}} object (resolution: 1:1 million, EPSG:4258) object with 8,131 rows and columns: \describe{ \item{codauto}{INE code of the autonomous community.} @@ -16,7 +16,8 @@ A \code{\link[sf:sf]{sf}} object (resolution: 1:1million, EPSG:4258) object with \item{cmun}{INE code of the municipality.} \item{name}{Name of the municipality.} \item{LAU_CODE}{LAU Code (GISCO) of the municipality. This is a -combination of \strong{cpro} and \strong{cmun}, aligned with INE coding scheme.} +combination of \strong{cpro} and \strong{cmun} fields, aligned with INE coding +scheme.} \item{geometry}{geometry field.} } } @@ -47,6 +48,7 @@ ggplot(teruel_sf) + values = "#C12838", labels = "City of Teruel" ) + + guides(fill = guide_legend(position = "inside")) + labs( fill = "", title = "Municipalities of Teruel" @@ -56,7 +58,7 @@ ggplot(teruel_sf) + text = element_text(face = "bold"), panel.background = element_rect(colour = "black"), panel.grid = element_blank(), - legend.position = c(.2, .95) + legend.position.inside = c(.2, .95) ) } \seealso{ diff --git a/man/esp_nuts.sf.Rd b/man/esp_nuts.sf.Rd index 67e7dff4..e90b6ea0 100644 --- a/man/esp_nuts.sf.Rd +++ b/man/esp_nuts.sf.Rd @@ -4,7 +4,7 @@ \encoding{UTF-8} \name{esp_nuts.sf} \alias{esp_nuts.sf} -\title{All NUTS \code{POLYGON} object of Spain} +\title{\code{\link[sf:sf]{sf}} object with all the NUTS levels of Spain (2016)} \format{ A \code{\link[sf:sf]{sf}} object (resolution: 1:1million, EPSG:4258) with 86 rows and columns: @@ -88,10 +88,7 @@ ggplot(nuts3) + title = "NUTS3 levels of Spain", fill = "Urban topology" ) + - theme_linedraw() + - theme( - legend.position = c(.8, .2) - ) + theme_linedraw() } \seealso{ Other datasets: diff --git a/man/esp_set_cache_dir.Rd b/man/esp_set_cache_dir.Rd index b3de3673..050889aa 100644 --- a/man/esp_set_cache_dir.Rd +++ b/man/esp_set_cache_dir.Rd @@ -15,12 +15,12 @@ esp_set_cache_dir( \item{cache_dir}{A path to a cache directory. On missing value the function would store the cached files on a temporary dir (See \code{\link[base:tempfile]{base::tempdir()}}).} -\item{overwrite}{If this is set to \code{TRUE}, it will overwrite an existing -\code{MAPSPAIN_CACHE_DIR} that you already have in local machine.} +\item{overwrite}{Logical. If this is set to \code{TRUE}, it will overwrite an +existing \code{MAPSPAIN_CACHE_DIR} that you already have in local machine.} -\item{install}{if \code{TRUE}, will install the key in your local machine for -use in future sessions. Defaults to \code{FALSE.} If \code{cache_dir} is \code{FALSE} -this parameter is set to \code{FALSE} automatically.} +\item{install}{Logical. If \code{TRUE}, will install the key in your local +machine for use in future sessions. Defaults to \code{FALSE.} If \code{cache_dir} +is \code{FALSE} this parameter is set to \code{FALSE} automatically.} \item{verbose}{Logical, displays information. Useful for debugging, default is \code{FALSE}.} diff --git a/man/esp_tiles_providers.Rd b/man/esp_tiles_providers.Rd index 174fd772..ec45beb1 100644 --- a/man/esp_tiles_providers.Rd +++ b/man/esp_tiles_providers.Rd @@ -4,9 +4,9 @@ \encoding{UTF-8} \name{esp_tiles_providers} \alias{esp_tiles_providers} -\title{List with information of Public WMS and WMTS of Spain} +\title{Database of public WMS and WMTS of Spain} \format{ -A named list of the providers available with the following structure: +A named \code{list} of the providers available with the following structure: \itemize{ \item Each item of the list is named with the provider alias. \item Each element of the list contains two nested named lists: @@ -23,9 +23,9 @@ named \code{attribution}. \strong{v1.3.3}. } \description{ -A named list of length 102 containing -the parameters of the url information of different public WMS and WMTS -providers of Spain. +A named \code{\link[base:list]{list}} of length 102 +containing the parameters of the url information of different public WMS and +WMTSproviders of Spain. Implementation of javascript plugin \href{https://dieghernan.github.io/leaflet-providersESP/}{leaflet-providersESP} diff --git a/man/leaflet.providersESP.df.Rd b/man/leaflet.providersESP.df.Rd index 189c7329..9560ec49 100644 --- a/man/leaflet.providersESP.df.Rd +++ b/man/leaflet.providersESP.df.Rd @@ -4,9 +4,9 @@ \encoding{UTF-8} \name{leaflet.providersESP.df} \alias{leaflet.providersESP.df} -\title{Public WMS and WMTS of Spain} +\title{(Superseded) Database of public WMS and WMTS of Spain} \format{ -A data frame object with a list of the required parameters for calling +A \code{data.frame} object with a list of the required parameters for calling the service: \describe{ \item{provider}{Provider name}. @@ -21,10 +21,10 @@ the service: \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}} -This data frame is not longer in use by \CRANpkg{mapSpain}. See +This \code{data.frame} is not longer in use by \CRANpkg{mapSpain}. See \link{esp_tiles_providers} instead. -A data frame containing information of different public WMS and WMTS +A \code{data.frame} containing information of different public WMS and WMTS providers of Spain } \examples{ diff --git a/man/pobmun19.Rd b/man/pobmun19.Rd index 5ba119ae..6ba96970 100644 --- a/man/pobmun19.Rd +++ b/man/pobmun19.Rd @@ -3,9 +3,9 @@ \docType{data} \name{pobmun19} \alias{pobmun19} -\title{Population by municipality (2019)} +\title{Database with the population of Spain by municipality (2019)} \format{ -An example data frame with +An example \code{data.frame} object with 8,131 rows containing the population data by municipality in Spain (2019). @@ -23,7 +23,7 @@ population data by municipality in Spain (2019). INE: Instituto Nacional de Estadistica \url{https://www.ine.es/} } \description{ -Population by municipality (2019) +Database with the population of Spain by municipality (2019) } \examples{ data("pobmun19") diff --git a/pkgdown/favicon/apple-touch-icon-120x120.png b/pkgdown/favicon/apple-touch-icon-120x120.png index 55ae08df..e4681d49 100644 Binary files a/pkgdown/favicon/apple-touch-icon-120x120.png and b/pkgdown/favicon/apple-touch-icon-120x120.png differ diff --git a/pkgdown/favicon/apple-touch-icon-152x152.png b/pkgdown/favicon/apple-touch-icon-152x152.png index 3614777f..b690e80d 100644 Binary files a/pkgdown/favicon/apple-touch-icon-152x152.png and b/pkgdown/favicon/apple-touch-icon-152x152.png differ diff --git a/pkgdown/favicon/apple-touch-icon-180x180.png b/pkgdown/favicon/apple-touch-icon-180x180.png index 11ef3e77..36424b02 100644 Binary files a/pkgdown/favicon/apple-touch-icon-180x180.png and b/pkgdown/favicon/apple-touch-icon-180x180.png differ diff --git a/pkgdown/favicon/apple-touch-icon-60x60.png b/pkgdown/favicon/apple-touch-icon-60x60.png index dffff689..98484b1b 100644 Binary files a/pkgdown/favicon/apple-touch-icon-60x60.png and b/pkgdown/favicon/apple-touch-icon-60x60.png differ diff --git a/pkgdown/favicon/apple-touch-icon-76x76.png b/pkgdown/favicon/apple-touch-icon-76x76.png index 2edd4942..a68c7c64 100644 Binary files a/pkgdown/favicon/apple-touch-icon-76x76.png and b/pkgdown/favicon/apple-touch-icon-76x76.png differ diff --git a/pkgdown/favicon/apple-touch-icon.png b/pkgdown/favicon/apple-touch-icon.png index 11ef3e77..36424b02 100644 Binary files a/pkgdown/favicon/apple-touch-icon.png and b/pkgdown/favicon/apple-touch-icon.png differ diff --git a/pkgdown/favicon/favicon-16x16.png b/pkgdown/favicon/favicon-16x16.png index e166fb60..de3e0a18 100644 Binary files a/pkgdown/favicon/favicon-16x16.png and b/pkgdown/favicon/favicon-16x16.png differ diff --git a/pkgdown/favicon/favicon-32x32.png b/pkgdown/favicon/favicon-32x32.png index aaaaa6b5..3b5fb4be 100644 Binary files a/pkgdown/favicon/favicon-32x32.png and b/pkgdown/favicon/favicon-32x32.png differ diff --git a/pkgdown/favicon/favicon.ico b/pkgdown/favicon/favicon.ico index b665f051..ce32a60f 100644 Binary files a/pkgdown/favicon/favicon.ico and b/pkgdown/favicon/favicon.ico differ diff --git a/tests/testthat/test-esp_make_provider.R b/tests/testthat/test-esp_make_provider.R index efde34ab..5fccbf59 100644 --- a/tests/testthat/test-esp_make_provider.R +++ b/tests/testthat/test-esp_make_provider.R @@ -36,6 +36,7 @@ test_that("Custom WMS provider", { id = "wms_1.1", q = "https://idecyl.jcyl.es/geoserver/ge/wms?", service = "WMS", + version = "1.1.1", crs = "EPSG:25830", layers = "geolog_cyl_litologia" ) @@ -51,8 +52,8 @@ test_that("Custom WMS provider", { # Both works - tilewms1 <- esp_getTiles(segovia, custom_wms_11) + tilewms1 <- esp_getTiles(segovia, custom_wms_11, cache_dir = tempdir()) expect_s4_class(tilewms1, "SpatRaster") - tilewms13 <- esp_getTiles(segovia, custom_wms_13) + tilewms13 <- esp_getTiles(segovia, custom_wms_13, cache_dir = tempdir()) expect_s4_class(tilewms13, "SpatRaster") }) diff --git a/vignettes/articles/x02_mapasesp.Rmd b/vignettes/articles/x02_mapasesp.Rmd index 434e5439..5b931d4c 100644 --- a/vignettes/articles/x02_mapasesp.Rmd +++ b/vignettes/articles/x02_mapasesp.Rmd @@ -45,13 +45,12 @@ Las **fuentes de información** empleadas en **mapSpain** son: - [GISCO](https://ec.europa.eu/eurostat/web/gisco) (Eurostat) via el paquete [**giscoR**](https://ropengov.github.io/giscoR/). - - [Instituto Geografico Nacional](https://www.ign.es/) (IGN) - - Distintos organismos públicos de España que proporcionan servicios de teselas WMTS/WMS (). -Los objetos resultantes se proporcionan en formato `sf` o `SpatRaster`(`terra`). +Los objetos resultantes se proporcionan en formato `sf` (librería **sf)** o +`SpatRaster`(librería **terra**). Página web: @@ -69,12 +68,13 @@ Usando el [r-universe](https://ropenspain.r-universe.dev/ui#builds): ```{r instruniverse, eval=FALSE} # Enable this universe -options(repos = c( - ropenspain = "https://ropenspain.r-universe.dev", - CRAN = "https://cloud.r-project.org" -)) - -install.packages("mapSpain", dependencies = TRUE) +install.packages("mapSpain", + repos = c( + "https://ropenspain.r-universe.dev", + "https://cloud.r-project.org" + ), + dependencies = TRUE +) ``` #### Remotes @@ -91,20 +91,13 @@ library(tidyverse) galicia <- esp_get_munic_siane(region = "Galicia") %>% # Homogeinizo labels - mutate( - Provincia = esp_dict_translate(ine.prov.name, "es") - ) + mutate(Provincia = esp_dict_translate(ine.prov.name, "es")) ggplot(galicia) + - geom_sf(aes(fill = Provincia), - color = "grey70" - ) + + geom_sf(aes(fill = Provincia), color = "grey70") + labs(title = "Provincias de Galicia") + - scale_fill_discrete( - type = - hcl.colors(4, "Blues") - ) + + scale_fill_discrete(type = hcl.colors(4, "Blues")) + theme_bw() ``` @@ -114,8 +107,7 @@ Si exploramos el dataset: library(reactable) reactable(galicia, - searchable = TRUE, striped = TRUE, - filterable = TRUE, height = 350, + searchable = TRUE, striped = TRUE, filterable = TRUE, height = 350, elementId = "munis-galicia" ) ``` @@ -136,10 +128,8 @@ esp_rnat <- ne_countries("large", country = "Spain", returnclass = "sf") esp_mapspain <- esp_get_country(epsg = 4326) # Imagen Ria Ferrol -tile <- esp_getTiles(esp_get_munic(munic = "Ferrol", epsg = 3857), - "IGNBase.Gris", - bbox_expand = 0.5, zoommin = 1 -) +tile <- esp_get_munic(munic = "Ferrol", epsg = 3857) %>% + esp_getTiles("IGNBase.Gris", bbox_expand = 0.5, zoommin = 1) # Prepara el plot library(tidyterra) @@ -151,14 +141,9 @@ esp_all$source <- c("rnaturalearth", "mapSpain") ggplot(esp_all) + geom_spatraster_rgb(data = tile, maxcell = Inf) + - geom_sf(aes(color = source), - fill = NA, show.legend = "line", - linewidth = 1.2 - ) + + geom_sf(aes(color = source), fill = NA, show.legend = "line", linewidth = 1.2) + coord_sf( - crs = 4326, - xlim = c(-8.384421, -8.154413), - ylim = c(43.43201, 43.59545), + crs = 4326, xlim = c(-8.384421, -8.154413), ylim = c(43.43201, 43.59545), expand = FALSE ) + scale_color_manual(values = c("red", "black")) + @@ -167,7 +152,6 @@ ggplot(esp_all) + ``` - **rnaturalearth**: No capta bien el contorno. - - **mapSpain**: Resultados satisfactorios. ### Almacenamiento @@ -209,13 +193,10 @@ códigos: - `esp_dict_region_code()` convierte textos en códigos de CCAA y provincias. Esquemas de codificación soportados: - - ISO2 - NUTS - INE (codauto y cpro) - - `esp_dict_translate()` traduce textos a diferentes idiomas: - - Castellano - Inglés - Catalán @@ -241,27 +222,19 @@ esp_dict_region_code(iso2vals, origin = "iso2") iso2vals <- c("ES-GA", "ES-CT", "ES-PV") -esp_dict_region_code(iso2vals, - origin = "iso2", - destination = "nuts" -) +esp_dict_region_code(iso2vals, origin = "iso2", destination = "nuts") # Soporta diferentes niveles valsmix <- c("Centro", "Andalucia", "Seville", "Menorca") esp_dict_region_code(valsmix, destination = "nuts") -esp_dict_region_code(c("Murcia", "Las Palmas", "Aragón"), - destination = "iso2" -) +esp_dict_region_code(c("Murcia", "Las Palmas", "Aragón"), destination = "iso2") ``` #### `esp_dict_translate()` ```{r} -vals <- c( - "La Rioja", "Sevilla", "Madrid", - "Jaen", "Orense", "Baleares" -) +vals <- c("La Rioja", "Sevilla", "Madrid", "Jaen", "Orense", "Baleares") esp_dict_translate(vals, lang = "en") esp_dict_translate(vals, lang = "es") @@ -350,15 +323,12 @@ ggplot(nuts3_sf) + ```{r ccaa} ccaa <- esp_get_ccaa(ccaa = c( - "Catalunya", - "Comunidad Valenciana", - "Aragón", + "Catalunya", "Comunidad Valenciana", "Aragón", "Baleares" )) -ccaa <- ccaa %>% mutate( - ccaa_cat = esp_dict_translate(ccaa$ine.ccaa.name, "ca") -) +ccaa <- ccaa %>% + mutate(ccaa_cat = esp_dict_translate(ine.ccaa.name, "ca")) ggplot(ccaa) + geom_sf(aes(fill = ccaa_cat)) + @@ -374,14 +344,12 @@ provincias de esa entidad. ```{r prov} provs <- esp_get_prov_siane(c( - "Andalucía", "Ciudad Real", - "Murcia", "Ceuta", "Melilla" + "Andalucía", "Ciudad Real", "Murcia", "Ceuta", + "Melilla" )) ggplot(provs) + - geom_sf(aes(fill = prov.shortname.es), - alpha = 0.9 - ) + + geom_sf(aes(fill = prov.shortname.es), alpha = 0.9) + scale_fill_discrete(type = hcl.colors(12, "Cividis")) + theme_minimal() + labs(fill = "Provincias") @@ -398,13 +366,11 @@ ggplot(munic) + geom_sf(aes(fill = pob19), alpha = 0.9, color = NA) + scale_fill_gradientn( colors = hcl.colors(100, "Inferno"), - n.breaks = 10, - labels = scales::label_comma(), + n.breaks = 10, labels = scales::label_comma(), guide = guide_legend() ) + labs( - fill = "Habitantes", - title = "Población en Segovia", + fill = "Habitantes", title = "Población en Segovia", subtitle = "Datos INE (2019)" ) + theme_void() + @@ -476,7 +442,8 @@ ggplot() + madrid <- esp_get_munic_siane(munic = "^Madrid$", epsg = 3857) madrid_mask <- esp_getTiles(madrid, "IGNBase.Gris", - mask = TRUE, crop = TRUE, zoommin = 2 + mask = TRUE, crop = TRUE, + zoommin = 2 ) diff --git a/vignettes/basic-1.png b/vignettes/basic-1.png index 1b6e4c61..8f38a224 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 302c600f..5fd8d381 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 2a04176e..a1f2526b 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 42178a6c..dae89b86 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 ffdf9709..78c53abd 100644 Binary files a/vignettes/giscoR-1.png and b/vignettes/giscoR-1.png differ diff --git a/vignettes/mapSpain.Rmd b/vignettes/mapSpain.Rmd index e86b5542..872c2e54 100644 --- a/vignettes/mapSpain.Rmd +++ b/vignettes/mapSpain.Rmd @@ -144,16 +144,16 @@ census <- mapSpain::pobmun19 codelist <- mapSpain::esp_codelist -census <- - unique(merge(census, codelist[, c("cpro", "codauto")], all.x = TRUE)) +census <- unique(merge(census, codelist[, c("cpro", "codauto")], all.x = TRUE)) # Summarize by CCAA -census_ccaa <- - aggregate(cbind(pob19, men, women) ~ codauto, data = census, sum) +census_ccaa <- aggregate(cbind(pob19, men, women) ~ codauto, data = census, sum) census_ccaa$porc_women <- census_ccaa$women / census_ccaa$pob19 -census_ccaa$porc_women_lab <- - paste0(round(100 * census_ccaa$porc_women, 2), "%") +census_ccaa$porc_women_lab <- paste0( + round(100 * census_ccaa$porc_women, 2), + "%" +) # Merge into spatial data @@ -168,9 +168,7 @@ ggplot(CCAA_sf) + ) + geom_sf(data = Can, color = "grey70") + geom_sf_label(aes(label = porc_women_lab), - fill = "white", alpha = 0.5, - size = 3, - label.size = 0 + fill = "white", alpha = 0.5, size = 3, label.size = 0 ) + scale_fill_gradientn( colors = hcl.colors(10, "Blues", rev = TRUE), @@ -178,10 +176,10 @@ ggplot(CCAA_sf) + labels = function(x) { sprintf("%1.1f%%", 100 * x) }, - guide = guide_legend(title = "Porc. women") + guide = guide_legend(title = "Porc. women", position = "inside") ) + theme_void() + - theme(legend.position = c(0.1, 0.6)) + theme(legend.position.inside = c(0.1, 0.6)) ```
@@ -223,14 +221,7 @@ ggplot(munic.pop) + scale_fill_manual( values = c("grey5", hcl.colors(length(br) - 2, "Spectral")), labels = prettyNum(c(0, br[-1]), big.mark = ","), - guide = guide_legend( - title = "Pop. per km2", - direction = "horizontal", - nrow = 1, - keywidth = 2, - title.position = "top", - label.position = "bottom" - ) + guide = guide_legend(title = "Pop. per km2", direction = "horizontal", nrow = 1) ) + labs(title = "Population density in Spain (2019)") + theme_void() + @@ -238,7 +229,10 @@ ggplot(munic.pop) + plot.title = element_text(hjust = .5), plot.background = element_rect(fill = "black"), text = element_text(colour = "white"), - legend.position = "bottom" + legend.position = "bottom", + legend.title.position = "top", + legend.text.position = "bottom", + legend.key.width = unit(30, "pt") ) ``` diff --git a/vignettes/mapSpain.Rmd.orig b/vignettes/mapSpain.Rmd.orig index 12e67982..76fc0970 100644 --- a/vignettes/mapSpain.Rmd.orig +++ b/vignettes/mapSpain.Rmd.orig @@ -55,7 +55,6 @@ of Spain. as: ```{r, eval=FALSE} - esp_set_cache_dir("./path/to/location") ``` @@ -68,7 +67,6 @@ same caching directory on both would speed up the data load on your session. Some examples of what **mapSpain** can do: ```{r basic, fig.cap="Example: Map of Spain", fig.asp=0.7} - library(mapSpain) library(ggplot2) @@ -89,7 +87,6 @@ ggplot(country) + face = "bold" ) ) - ``` ```{r basic2, fig.cap="Example: Provinces of Andalucia", fig.asp=0.55} @@ -134,23 +131,22 @@ Let's analyze the distribution of women in each autonomous community with `ggplot`: ```{r choro, fig.cap="Percentage of women by Autonomous Community (2019)", fig.asp=0.7} - census <- mapSpain::pobmun19 # Extract CCAA from base dataset codelist <- mapSpain::esp_codelist -census <- - unique(merge(census, codelist[, c("cpro", "codauto")], all.x = TRUE)) +census <- unique(merge(census, codelist[, c("cpro", "codauto")], all.x = TRUE)) # Summarize by CCAA -census_ccaa <- - aggregate(cbind(pob19, men, women) ~ codauto, data = census, sum) +census_ccaa <- aggregate(cbind(pob19, men, women) ~ codauto, data = census, sum) census_ccaa$porc_women <- census_ccaa$women / census_ccaa$pob19 -census_ccaa$porc_women_lab <- - paste0(round(100 * census_ccaa$porc_women, 2), "%") +census_ccaa$porc_women_lab <- paste0( + round(100 * census_ccaa$porc_women, 2), + "%" +) # Merge into spatial data @@ -165,9 +161,7 @@ ggplot(CCAA_sf) + ) + geom_sf(data = Can, color = "grey70") + geom_sf_label(aes(label = porc_women_lab), - fill = "white", alpha = 0.5, - size = 3, - label.size = 0 + fill = "white", alpha = 0.5, size = 3, label.size = 0 ) + scale_fill_gradientn( colors = hcl.colors(10, "Blues", rev = TRUE), @@ -175,10 +169,10 @@ ggplot(CCAA_sf) + labels = function(x) { sprintf("%1.1f%%", 100 * x) }, - guide = guide_legend(title = "Porc. women") + guide = guide_legend(title = "Porc. women", position = "inside") ) + theme_void() + - theme(legend.position = c(0.1, 0.6)) + theme(legend.position.inside = c(0.1, 0.6)) ``` ## Thematic maps @@ -190,7 +184,6 @@ handles `sf` objects (e.g. **tmap**, **mapsf**, **leaflet**, etc. could be used). ```{r thematic, fig.cap="Population density in Spain (2019)", crop=TRUE, dpi=120} - # Population density of Spain library(sf) @@ -212,16 +205,10 @@ munic.pop$cuts <- cut(munic.pop$dens, br) ggplot(munic.pop) + geom_sf(aes(fill = cuts), color = NA, linewidth = 0) + - scale_fill_manual(values = c("grey5", hcl.colors(length(br) - 2,"Spectral")), + scale_fill_manual( + values = c("grey5", hcl.colors(length(br) - 2, "Spectral")), labels = prettyNum(c(0, br[-1]), big.mark = ","), - guide = guide_legend( - title = "Pop. per km2", - direction = "horizontal", - nrow = 1, - keywidth = 2, - title.position = "top", - label.position = "bottom" - ) + guide = guide_legend(title = "Pop. per km2", direction = "horizontal", nrow = 1) ) + labs(title = "Population density in Spain (2019)") + theme_void() + @@ -229,7 +216,10 @@ ggplot(munic.pop) + plot.title = element_text(hjust = .5), plot.background = element_rect(fill = "black"), text = element_text(colour = "white"), - legend.position = "bottom" + legend.position = "bottom", + legend.title.position = "top", + legend.text.position = "bottom", + legend.key.width = unit(30, "pt") ) ``` @@ -240,7 +230,6 @@ If you need to plot Spain along with another countries, consider using dependency when you installed **mapSpain**. A basic example: ```{r giscoR, fig.cap="mapSpain and giscoR example", fig.asp=0.9} - library(giscoR) # Set the same resolution for a perfect fit @@ -251,11 +240,13 @@ all_countries <- gisco_get_countries(resolution = res) |> st_transform(3035) eu_countries <- gisco_get_countries( - resolution = res, region = "EU") |> + resolution = res, region = "EU" +) |> st_transform(3035) ccaa <- esp_get_ccaa( - moveCAN = FALSE, resolution = res) |> + moveCAN = FALSE, resolution = res +) |> st_transform(3035) # Plot @@ -275,7 +266,6 @@ ggplot(all_countries) + linetype = "dotted" ) ) - ``` ## Working with tiles diff --git a/vignettes/thematic-1.png b/vignettes/thematic-1.png index 42fdfc68..ba43d3a2 100644 Binary files a/vignettes/thematic-1.png and b/vignettes/thematic-1.png differ