From 5b29be3a45d7bc6bcc9fd59e5cfd624646cc32bf Mon Sep 17 00:00:00 2001 From: rCarto Date: Mon, 15 Jan 2024 11:43:47 +0100 Subject: [PATCH] fix: use the same provider names as leaflet fix #31 --- R/get_tiles.R | 14 +++++++------- R/providers.R | 36 ++++++++++++++++++------------------ R/utils.R | 3 ++- man/get_tiles.Rd | 12 ++++++------ man/maptiles.Rd | 2 +- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/R/get_tiles.R b/R/get_tiles.R index 106e5ee..a5caa06 100644 --- a/R/get_tiles.R +++ b/R/get_tiles.R @@ -26,12 +26,12 @@ #' Providers: \cr #' "OpenStreetMap", "OpenStreetMap.DE", "OpenStreetMap.France", #' "OpenStreetMap.HOT", "OpenTopoMap", \cr -#' "Stadia.Stamen.Toner", "Stadia.Stamen.TonerBackground", -#' "Stadia.Stamen.TonerLines", "Stadia.Stamen.TonerLabels", -#' "Stadia.Stamen.TonerLite", -#' "Stadia.Stamen.Watercolor", "Stadia.Stamen.Terrain", -#' "Stadia.Stamen.TerrainBackground", -#' "Stadia.Stamen.TerrainLabels", \cr +#' "Stadia.StamenToner", "Stadia.StamenTonerBackground", +#' "Stadia.StamenTonerLines", "Stadia.StamenTonerLabels", +#' "Stadia.StamenTonerLite", +#' "Stadia.StamenWatercolor", "Stadia.StamenTerrain", +#' "Stadia.StamenTerrainBackground", +#' "Stadia.StamenTerrainLabels", \cr #' "Esri.WorldStreetMap", #' "Esri.WorldTopoMap", "Esri.WorldImagery", "Esri.WorldTerrain", #' "Esri.WorldShadedRelief", "Esri.OceanBasemap", "Esri.NatGeoWorldMap", @@ -49,7 +49,7 @@ #' "Thunderforest.Neighbourhood" #' @export #' @return A SpatRaster is returned. -#' @importFrom terra ext project rast as.polygons 'RGB<-' gdal writeRaster +#' @importFrom terra ext project rast as.polygons gdal writeRaster #' @importFrom sf st_is st_transform st_geometry<- st_buffer st_geometry #' st_bbox st_as_sfc st_crs #' @importFrom tools file_path_sans_ext diff --git a/R/providers.R b/R/providers.R index 2e4a9c6..b97c8b6 100644 --- a/R/providers.R +++ b/R/providers.R @@ -34,56 +34,56 @@ globalVariables(".global_maptiles", package = "maptiles", add = FALSE) sub = c("a", "b", "c"), cit = "Map data: \ua9 OpenStreetMap contributors | Map style: \ua9 OpenTopoMap (CC-BY-SA)" ), - Stadia.Stamen.Toner = list( - src = "Stadia.Stamen.Toner", + Stadia.StamenToner = list( + src = "Stadia.StamenToner", q = "https://tiles.stadiamaps.com/tiles/stamen_toner/{z}/{x}/{y}.png?api_key={apikey}", sub = NA, cit = "\ua9 Stadia Maps \ua9 Stamen Design \ua9 OpenMapTiles \ua9 OpenStreetMap contributors" ), - Stadia.Stamen.TonerBackground = list( - src = "Stadia.Stamen.TonerBackground", + Stadia.StamenTonerBackground = list( + src = "Stadia.StamenTonerBackground", q = "https://tiles.stadiamaps.com/tiles/stamen_toner_background/{z}/{x}/{y}.png?api_key={apikey}", sub = NA, cit = "\ua9 Stadia Maps \ua9 Stamen Design \ua9 OpenMapTiles \ua9 OpenStreetMap contributors" ), - Stadia.Stamen.TonerLines = list( - src = "Stadia.Stamen.TonerLines", + Stadia.StamenTonerLines = list( + src = "Stadia.StamenTonerLines", q = "https://tiles.stadiamaps.com/tiles/stamen_toner_lines/{z}/{x}/{y}.png?api_key={apikey}", sub = NA, cit = "\ua9 Stadia Maps \ua9 Stamen Design \ua9 OpenMapTiles \ua9 OpenStreetMap contributors" ), - Stadia.Stamen.TonerLabels = list( - src = "Stadia.Stamen.TonerLabels", + Stadia.StamenTonerLabels = list( + src = "Stadia.StamenTonerLabels", q = "https://tiles.stadiamaps.com/tiles/stamen_toner_labels/{z}/{x}/{y}.png?api_key={apikey}", sub = NA, cit = "\ua9 Stadia Maps \ua9 Stamen Design \ua9 OpenMapTiles \ua9 OpenStreetMap contributors" ), - Stadia.Stamen.TonerLite = list( - src = "Stadia.Stamen.TonerLite", + Stadia.StamenTonerLite = list( + src = "Stadia.StamenTonerLite", q = "https://tiles.stadiamaps.com/tiles/stamen_toner_lite/{z}/{x}/{y}.png?api_key={apikey}", sub = NA, cit = "\ua9 Stadia Maps \ua9 Stamen Design \ua9 OpenMapTiles \ua9 OpenStreetMap contributors" ), - Stadia.Stamen.Watercolor = list( - src = "Stadia.Stamen.Watercolor", + Stadia.StamenWatercolor = list( + src = "Stadia.StamenWatercolor", q = "https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg?api_key={apikey}", sub = NA, cit = "\ua9 Stadia Maps \ua9 Stamen Design \ua9 OpenStreetMap contributors" ), - Stadia.Stamen.Terrain = list( - src = "Stadia.Stamen.Terrain", + Stadia.StamenTerrain = list( + src = "Stadia.StamenTerrain", q = "https://tiles.stadiamaps.com/tiles/stamen_terrain/{z}/{x}/{y}.png?api_key={apikey}", sub = NA, cit = "\ua9 Stadia Maps \ua9 Stamen Design \ua9 OpenMapTiles \ua9 OpenStreetMap contributors" ), - Stadia.Stamen.TerrainBackground = list( - src = "Stadia.Stamen.TerrainBackground", + Stadia.StamenTerrainBackground = list( + src = "Stadia.StamenTerrainBackground", q = "https://tiles.stadiamaps.com/tiles/stamen_terrain_background/{z}/{x}/{y}.png?api_key={apikey}", sub = NA, cit = "\ua9 Stadia Maps \ua9 Stamen Design \ua9 OpenMapTiles \ua9 OpenStreetMap contributors" ), - Stadia.Stamen.TerrainLabels = list( - src = "Stadia.Stamen.TerrainLabels", + Stadia.StamenTerrainLabels = list( + src = "Stadia.StamenTerrainLabels", q = "https://tiles.stadiamaps.com/tiles/stamen_terrain_labels/{z}/{x}/{y}.png?api_key={apikey}", sub = NA, cit = "\ua9 Stadia Maps \ua9 Stamen Design \ua9 OpenMapTiles \ua9 OpenStreetMap contributors" diff --git a/R/utils.R b/R/utils.R index a4db38d..4818d49 100644 --- a/R/utils.R +++ b/R/utils.R @@ -105,6 +105,7 @@ get_param <- function(provider) { stop(paste0("'",provider,"' is not a builtin provider."), call. = FALSE) } if (provider %in% stamen_provider) { + provider <- gsub("\\.", "", provider) provider <- paste0("Stadia.", provider) warning( paste0( @@ -296,6 +297,6 @@ project_and_crop_raster <- function(ras, project, res, crop) { ras <- terra::crop(x = ras, y = bbox_output[c(1, 3, 2, 4)], snap = "out") } # set R, G, B channels, such that plot(ras) will go to plotRGB - RGB(ras) <- 1:3 + terra::RGB(ras) <- 1:3 return(ras) } diff --git a/man/get_tiles.Rd b/man/get_tiles.Rd index f106adf..e719c5d 100644 --- a/man/get_tiles.Rd +++ b/man/get_tiles.Rd @@ -57,12 +57,12 @@ Zoom levels are described in the OpenStreetMap wiki: Providers: \cr "OpenStreetMap", "OpenStreetMap.DE", "OpenStreetMap.France", "OpenStreetMap.HOT", "OpenTopoMap", \cr -"Stadia.Stamen.Toner", "Stadia.Stamen.TonerBackground", -"Stadia.Stamen.TonerLines", "Stadia.Stamen.TonerLabels", -"Stadia.Stamen.TonerLite", -"Stadia.Stamen.Watercolor", "Stadia.Stamen.Terrain", -"Stadia.Stamen.TerrainBackground", -"Stadia.Stamen.TerrainLabels", \cr +"Stadia.StamenToner", "Stadia.StamenTonerBackground", +"Stadia.StamenTonerLines", "Stadia.StamenTonerLabels", +"Stadia.StamenTonerLite", +"Stadia.StamenWatercolor", "Stadia.StamenTerrain", +"Stadia.StamenTerrainBackground", +"Stadia.StamenTerrainLabels", \cr "Esri.WorldStreetMap", "Esri.WorldTopoMap", "Esri.WorldImagery", "Esri.WorldTerrain", "Esri.WorldShadedRelief", "Esri.OceanBasemap", "Esri.NatGeoWorldMap", diff --git a/man/maptiles.Rd b/man/maptiles.Rd index b0cb757..fe2c3ef 100644 --- a/man/maptiles.Rd +++ b/man/maptiles.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/pkg.R \docType{package} \name{maptiles} -\alias{maptiles} \alias{maptiles-package} +\alias{maptiles} \title{Download and Display Map Tiles} \description{ To create maps from tiles, maptiles downloads, composes and displays tiles