From 3ab9b74d86fd0142aa21d3259eb329986f55cb94 Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Mon, 25 Sep 2023 13:54:45 -0500 Subject: [PATCH 01/15] print tile url --- R/internal.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/internal.R b/R/internal.R index e05f057..356cb72 100644 --- a/R/internal.R +++ b/R/internal.R @@ -174,6 +174,7 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) + print(url) if(isTRUE(http_error(url))){ resp <- GET(url) From cae04e46c5da13f5455f813ed52f60047d0b253d Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Mon, 25 Sep 2023 15:45:27 -0500 Subject: [PATCH 02/15] add USGS tileset options --- R/internal.R | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/R/internal.R b/R/internal.R index 356cb72..52ddee8 100644 --- a/R/internal.R +++ b/R/internal.R @@ -174,7 +174,6 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) - print(url) if(isTRUE(http_error(url))){ resp <- GET(url) @@ -502,7 +501,16 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge world_reference_overlay = "https://services.arcgisonline.com/arcgis/rest/services/Reference/World_Reference_Overlay/MapServer/tile/", world_transportation = "https://services.arcgisonline.com/arcgis/rest/services/Reference/World_Transportation/MapServer/tile/", delorme_world_base_map = "https://services.arcgisonline.com/arcgis/rest/services/Specialty/DeLorme_World_Base_Map/MapServer/tile/", - world_navigation_charts = "https://services.arcgisonline.com/arcgis/rest/services/Specialty/World_Navigation_Charts/MapServer/tile/") + world_navigation_charts = "https://services.arcgisonline.com/arcgis/rest/services/Specialty/World_Navigation_Charts/MapServer/tile/" + ), + usgs = list( + hydro_cached = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSHydroCached/MapServer/tile/", + imagery_only = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/", + imagery_topo = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryTopo/MapServer/tile/", + shaded_relief = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/tile/", + national_map = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSTNMBlank/MapServer/tile/", + topo = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/" + ) )) if(!dir.exists(getOption("basemaps.defaults")$map_dir)) dir.create(getOption("basemaps.defaults")$map_dir) From 44bb79be4f8292b9e737d9f50491b2fa267023bf Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Mon, 25 Sep 2023 21:21:39 -0500 Subject: [PATCH 03/15] use {z}/{y}/{x} instead of {z}/{x}/{y} for USGS tile URLs --- R/internal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/internal.R b/R/internal.R index 52ddee8..359b5b0 100644 --- a/R/internal.R +++ b/R/internal.R @@ -169,7 +169,7 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge # download tiles url <- paste0( getOption("basemaps.map_api")[[map_service]][[map_type]], tg$zoom, "/", # base URL - if(map_service == "esri") paste0(x[2], "/", x[1]) else paste0(x[1], "/", x[2]), # coordinate order + if(map_service == "esri" || map_service == "usgs") paste0(x[2], "/", x[1]) else paste0(x[1], "/", x[2]), # coordinate order if(any(map_service != "mapbox", all(map_service == "mapbox", map_type == "terrain"))) ".png", # file suffix or not if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not From 6a195f3ec04e529abaf028e7d0911a981fb736cc Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Mon, 25 Sep 2023 23:06:50 -0500 Subject: [PATCH 04/15] revert tile url order --- R/internal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/internal.R b/R/internal.R index 359b5b0..52ddee8 100644 --- a/R/internal.R +++ b/R/internal.R @@ -169,7 +169,7 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge # download tiles url <- paste0( getOption("basemaps.map_api")[[map_service]][[map_type]], tg$zoom, "/", # base URL - if(map_service == "esri" || map_service == "usgs") paste0(x[2], "/", x[1]) else paste0(x[1], "/", x[2]), # coordinate order + if(map_service == "esri") paste0(x[2], "/", x[1]) else paste0(x[1], "/", x[2]), # coordinate order if(any(map_service != "mapbox", all(map_service == "mapbox", map_type == "terrain"))) ".png", # file suffix or not if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not From f90857ef8dcc35f8fa48f0455b3aef8494a903af Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Mon, 25 Sep 2023 23:25:23 -0500 Subject: [PATCH 05/15] add logging --- R/internal.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/internal.R b/R/internal.R index 52ddee8..123c6f9 100644 --- a/R/internal.R +++ b/R/internal.R @@ -174,6 +174,7 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) + log_info(sprintf("URL: " %s, url)) if(isTRUE(http_error(url))){ resp <- GET(url) From 49c22e18f662c6e3098351f1db23476a09e5b7c2 Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Mon, 25 Sep 2023 23:31:24 -0500 Subject: [PATCH 06/15] Update internal.R --- R/internal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/internal.R b/R/internal.R index 123c6f9..9844e89 100644 --- a/R/internal.R +++ b/R/internal.R @@ -174,7 +174,7 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) - log_info(sprintf("URL: " %s, url)) + logger::log_info(sprintf("URL: %s", url)) if(isTRUE(http_error(url))){ resp <- GET(url) From d5bddb888b30ff1f2aac2c4d30b9675edf4afce6 Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Mon, 25 Sep 2023 23:45:52 -0500 Subject: [PATCH 07/15] Update internal.R --- R/internal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/internal.R b/R/internal.R index 9844e89..bcde478 100644 --- a/R/internal.R +++ b/R/internal.R @@ -174,7 +174,7 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) - logger::log_info(sprintf("URL: %s", url)) + out(sprintf("URL: %s", url)) if(isTRUE(http_error(url))){ resp <- GET(url) From dbeefb98d8da76b23877426782218bcf8a192cb1 Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Mon, 25 Sep 2023 23:56:55 -0500 Subject: [PATCH 08/15] add classify output type --- R/internal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/internal.R b/R/internal.R index bcde478..75f453a 100644 --- a/R/internal.R +++ b/R/internal.R @@ -174,7 +174,7 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) - out(sprintf("URL: %s", url)) + out(paste("URL:", url), type = 3) if(isTRUE(http_error(url))){ resp <- GET(url) From 399c53754c2b23bbd4f8b17797fbb5372206f6a2 Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Tue, 26 Sep 2023 00:05:45 -0500 Subject: [PATCH 09/15] switch tile URL variables --- R/internal.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/internal.R b/R/internal.R index 75f453a..baeff8a 100644 --- a/R/internal.R +++ b/R/internal.R @@ -169,12 +169,12 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge # download tiles url <- paste0( getOption("basemaps.map_api")[[map_service]][[map_type]], tg$zoom, "/", # base URL - if(map_service == "esri") paste0(x[2], "/", x[1]) else paste0(x[1], "/", x[2]), # coordinate order + if(map_service %in% list("esri", "usgs")) paste0(x[2], "/", x[1]) else paste0(x[1], "/", x[2]), # coordinate order if(any(map_service != "mapbox", all(map_service == "mapbox", map_type == "terrain"))) ".png", # file suffix or not if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) - out(paste("URL:", url), type = 3) + out(paste("URL:", url), type = 1) if(isTRUE(http_error(url))){ resp <- GET(url) From b4d8b24453da6e1a216d449ce92f98762b60c76e Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Tue, 26 Sep 2023 00:37:08 -0500 Subject: [PATCH 10/15] drop .png from USGS tile URLs --- R/internal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/internal.R b/R/internal.R index baeff8a..0afc73c 100644 --- a/R/internal.R +++ b/R/internal.R @@ -170,7 +170,7 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge url <- paste0( getOption("basemaps.map_api")[[map_service]][[map_type]], tg$zoom, "/", # base URL if(map_service %in% list("esri", "usgs")) paste0(x[2], "/", x[1]) else paste0(x[1], "/", x[2]), # coordinate order - if(any(map_service != "mapbox", all(map_service == "mapbox", map_type == "terrain"))) ".png", # file suffix or not + if(any(!(map_service %in% list("mapbox", "usgs")), all(map_service == "mapbox", map_type == "terrain"))) ".png", # file suffix or not if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) From 973067836018ef9bad7d3c6e1d80577179efad01 Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Tue, 26 Sep 2023 01:01:40 -0500 Subject: [PATCH 11/15] remove logging & update docs --- R/get_maptypes.R | 2 ++ R/internal.R | 1 - README.md | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/R/get_maptypes.R b/R/get_maptypes.R index 7ab89f5..17e6ed6 100644 --- a/R/get_maptypes.R +++ b/R/get_maptypes.R @@ -20,6 +20,8 @@ #' #' \code{"esri"}: Esri (\url{https://www.esri.com/en-us/home}) #' +#' \code{"usgs"}: USGS (\url{https://basemap.nationalmap.gov/arcgis/rest/services}) +#' #' @examples #' # for all services #' get_maptypes() diff --git a/R/internal.R b/R/internal.R index 0afc73c..e3ebdfd 100644 --- a/R/internal.R +++ b/R/internal.R @@ -174,7 +174,6 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) - out(paste("URL:", url), type = 1) if(isTRUE(http_error(url))){ resp <- GET(url) diff --git a/README.md b/README.md index 2e08181..586c4e8 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,12 @@ This table lists all currently implemented map services and map types and indica | `esri` | `world_transportation` | no | | `esri` | `delorme_world_base_map` | no | | `esri` | `world_navigation_charts` | no | +| `usgs` | `hydro_cached` | no | +| `usgs` | `imagery_only` | no | +| `usgs` | `imagery_topo` | no | +| `usgs` | `shaded_relief` | no | +| `usgs` | `national_map` | no | +| `usgs` | `topo` | no | ## Available functions From 16670fb0e37baa49b880d83afe24308c3651e17b Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Tue, 26 Sep 2023 01:08:48 -0500 Subject: [PATCH 12/15] restore tile URL logging --- R/internal.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/internal.R b/R/internal.R index e3ebdfd..81271e2 100644 --- a/R/internal.R +++ b/R/internal.R @@ -174,6 +174,7 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) + out(" ", type = 1) if(isTRUE(http_error(url))){ resp <- GET(url) From 2683a1b1364e443def91c18c7a0c87f904310958 Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Tue, 26 Sep 2023 01:21:45 -0500 Subject: [PATCH 13/15] fix logging --- R/internal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/internal.R b/R/internal.R index 81271e2..d3a229e 100644 --- a/R/internal.R +++ b/R/internal.R @@ -174,7 +174,7 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) - out(" ", type = 1) + out(url, type = 1) if(isTRUE(http_error(url))){ resp <- GET(url) From caf038a17ea229050a7c532638642c10dd421241 Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Tue, 26 Sep 2023 01:49:37 -0500 Subject: [PATCH 14/15] remove USGS National Map option & logging --- R/internal.R | 2 -- README.md | 1 - 2 files changed, 3 deletions(-) diff --git a/R/internal.R b/R/internal.R index d3a229e..dd31b7d 100644 --- a/R/internal.R +++ b/R/internal.R @@ -174,7 +174,6 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge if(map_service == "mapbox") paste0("?access_token=", map_token), # token or not if(map_service == "osm_thunderforest") paste0("?apikey=", map_token) # token or not ) - out(url, type = 1) if(isTRUE(http_error(url))){ resp <- GET(url) @@ -509,7 +508,6 @@ out <- function(input, type = 1, ll = NULL, msg = FALSE, sign = "", verbose = ge imagery_only = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/", imagery_topo = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryTopo/MapServer/tile/", shaded_relief = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/tile/", - national_map = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSTNMBlank/MapServer/tile/", topo = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/" ) )) diff --git a/README.md b/README.md index 586c4e8..7eb1db0 100644 --- a/README.md +++ b/README.md @@ -266,7 +266,6 @@ This table lists all currently implemented map services and map types and indica | `usgs` | `imagery_only` | no | | `usgs` | `imagery_topo` | no | | `usgs` | `shaded_relief` | no | -| `usgs` | `national_map` | no | | `usgs` | `topo` | no | ## Available functions From 0ecbbf0fcaae5e16cd042b70d498a6a0ee59ea07 Mon Sep 17 00:00:00 2001 From: Nate Copeland Date: Mon, 18 Nov 2024 11:03:10 -0600 Subject: [PATCH 15/15] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7eb1db0..d3ee0c3 100644 --- a/README.md +++ b/README.md @@ -262,11 +262,11 @@ This table lists all currently implemented map services and map types and indica | `esri` | `world_transportation` | no | | `esri` | `delorme_world_base_map` | no | | `esri` | `world_navigation_charts` | no | -| `usgs` | `hydro_cached` | no | -| `usgs` | `imagery_only` | no | -| `usgs` | `imagery_topo` | no | -| `usgs` | `shaded_relief` | no | -| `usgs` | `topo` | no | +| `usgs` | `hydro_cached` (max zoom: 16) | no | +| `usgs` | `imagery_only` (max zoom: 16) | no | +| `usgs` | `imagery_topo` (max zoom: 16) | no | +| `usgs` | `shaded_relief` (max zoom: 16) | no | +| `usgs` | `topo` (max zoom: 16) | no | ## Available functions