Was playing around with this package {basemaps} and i think it might be useful if we ever wanted to create static basemaps behind the shapefiles for context. It seems to be able to find the appropriate zoom level based on the extent of the sf feature.
Probably too much work/testing required for initial release, but could be something to keep in mind/explore more
here you can see the map types offered in the package. Only ESRI and Carto are offered out of the box without API tokens. However I suspect some of the ones with tokens would be even better/more appropriate.
Here is a little preview of a few of the "nice" ones for our application. I could imagine something without many boundaries, but a few labels/topographic features for context being ideal as that would allow us to superimpose the adm0 of interest without any conflicting lines
sf_webmercator <- st_transform(sf_adm0 ,"EPSG:3857")
ggplot() +
basemap_gglayer(
sf_webmercator,
map_service = "carto",
map_type = "voyager"
) +
scale_fill_identity() +
coord_sf()+
geom_sf(data= sf_webmercator, fill="transparent",color="black")+
geom_sf(data= sf_webmercator, fill="transparent",color="black")+
labs(
x = "",
y = "",
subtitle = "Carto - Voyager",
) +
theme(
rect = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_blank(),
plot.caption = element_text(hjust = 1)
)
#> Loading basemap 'voyager' from map service 'carto'...
#> Using geom_raster() with maxpixels = 255425.
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.
ggplot() +
basemap_gglayer(
sf_webmercator,
map_service = "carto",
map_type = "light_no_labels"
) +
scale_fill_identity() +
coord_sf()+
geom_sf(data= sf_webmercator, fill="transparent",color="black")+
labs(
x = "",
y = "",
title = "Carto - Light no labels"
) +
theme(
rect = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_blank(),
plot.caption = element_text(hjust = 1)
)
#> Loading basemap 'light_no_labels' from map service 'carto'...
#> Using geom_raster() with maxpixels = 255425.
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.
ggplot() +
basemap_gglayer(
sf_webmercator,
map_service = "esri",
map_type = "world_street_map"
) +
scale_fill_identity() +
coord_sf()+
geom_sf(data= sf_webmercator, fill="transparent",color="black")+
labs(
x = "",
y = "",
subtitle = "ESRI - World Street Map",
) +
theme(
rect = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_blank(),
plot.caption = element_text(hjust = 1)
)
#> Loading basemap 'world_street_map' from map service 'esri'...
#> Using geom_raster() with maxpixels = 255425.
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.
ggplot() +
basemap_gglayer(
sf_webmercator,
map_service = "esri",
map_type = "world_light_gray_base"
) +
scale_fill_identity() +
coord_sf()+
geom_sf(data= sf_webmercator, fill="transparent",color="black")+
labs(
x = "",
y = "",
subtitle = "ESRI - World light grey base",
) +
theme(
rect = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_blank(),
plot.caption = element_text(hjust = 1)
)
#> Loading basemap 'world_light_gray_base' from map service 'esri'...
#> Using geom_raster() with maxpixels = 255425.
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.
ggplot() +
basemap_gglayer(
sf_webmercator,
map_service = "esri",
map_type = "world_light_gray_reference"
) +
scale_fill_identity() +
coord_sf()+
geom_sf(data= sf_webmercator, fill="transparent",color="black")+
labs(
x = "",
y = "",
subtitle = "ESRI - World light grey base",
) +
theme(
rect = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_blank(),
plot.caption = element_text(hjust = 1)
)
#> Loading basemap 'world_light_gray_reference' from map service 'esri'...
#> Using geom_tile() with maxpixels = 255425.
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.
ggplot() +
basemap_gglayer(
sf_webmercator,
map_service = "esri",
map_type = "natgeo_world_map"
) +
scale_fill_identity() +
coord_sf()+
geom_sf(data= sf_webmercator, fill="transparent",color="black")+
labs(
x = "",
y = "",
subtitle = "ESRI - NatGeo",
) +
theme(
rect = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_blank(),
plot.caption = element_text(hjust = 1)
)
#> Loading basemap 'natgeo_world_map' from map service 'esri'...
#> Using geom_raster() with maxpixels = 255425.
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.
Was playing around with this package
{basemaps}
and i think it might be useful if we ever wanted to create static basemaps behind the shapefiles for context. It seems to be able to find the appropriate zoom level based on the extent of the sf feature.Probably too much work/testing required for initial release, but could be something to keep in mind/explore more
here you can see the map types offered in the package. Only ESRI and Carto are offered out of the box without API tokens. However I suspect some of the ones with tokens would be even better/more appropriate.
Here is a little preview of a few of the "nice" ones for our application. I could imagine something without many boundaries, but a few labels/topographic features for context being ideal as that would allow us to superimpose the adm0 of interest without any conflicting lines
Created on 2024-06-05 with reprex v2.0.2