-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basemaps #43
Comments
This would be a really nice feature. Of the basemap layers you use from the BCGW, what are the top ones you use for creating maps? |
Typically everything in the base maps auto scale, most importantly the transportation lines, major cities and water bodies/rivers. The only one I turn off is typically elevation points. |
Nice idea. What data licence are the base maps distributed under? |
Similar to what we are doing here #74, we could use these as basemaps: https://pub.data.gov.bc.ca/datasets/177864/tif/bcalb |
For posterity just adding this as a possibility for basemaps: library(tmap)
library(bcmaps)
#> Loading required package: sf
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(sf)
library(raster)
#> Loading required package: sp
url <- "https://pub.data.gov.bc.ca/datasets/177864/tif/bcalb/092k/bc_092k_xc10m_bcalb.zip"
zip_path <- tempfile(fileext = ".zip")
download.file(url, destfile = zip_path)
tif_dir <- tempdir()
unzip(zip_path, exdir = tif_dir)
base <- brick(list.files(tif_dir, pattern = "tif", full.names = TRUE))
rd <- regional_districts() %>%
st_transform(raster::crs(base)) %>%
st_intersection(st_bbox(base) %>% st_as_sfc()) %>%
st_intersection(bc_bound() %>% st_transform(raster::crs(base)))
#> regional_districts was updated on 2020-08-26
#> Warning: attribute variables are assumed to be spatially constant throughout all
#> geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all
#> geometries
tm_shape(base) +
tm_rgb() +
tm_shape(rd) +
tm_polygons(border.col = "black", alpha = 0.2, col = "ADMIN_AREA_NAME") +
tm_layout(legend.outside = TRUE)
#> stars object downsampled to 1122 by 891 cells. See tm_shape manual (argument raster.downsample)
#> Some legend labels were too wide. These labels have been resized to 0.62, 0.57, 0.66. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger. |
You can also add BC Gov WMS services to leaflet. No functions needed, just a good FYI and potential vignette for pretty leaflet maps for BC.
|
Hi, was curious if there was any further suggestion/guidance for building basemaps? |
@David-Rattray I think if you are looking to recreate a map like the one you shared in It you are interested in having WMS/WMTS layers in static maps... that may be a bit trickier!.. maybe using something like: https://github.com/hypertidy/ceramic ? library(bcmaps)
#> Loading required package: sf
#> Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE
#> Support for Spatial objects (`sp`) was removed in {bcmaps} v2.0.0. Please use `sf` objects with {bcmaps}.
library(tmap)
#> Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
#> remotes::install_github('r-tmap/tmap')
bc_neighbours <- bcmaps::bc_neighbours()
#> bc_neighbours was updated on 2024-01-30
bc_cities <- bcmaps::bc_cities()
watercourses_5M <- bcmaps::watercourses_5M()
tm_shape(bc_neighbours) + tm_fill(col = "iso_a2", palette = c("grey90","steelblue1","grey80"), legend.show = F) + tm_borders() +
tm_shape(bc_cities) + tm_dots(size = 0.3, shape = 1) +
tm_shape(watercourses_5M) + tm_lines(col = "steelblue") Created on 2024-01-30 with reprex v2.0.2 |
Thanks for your comment @David-Rattray. Are you looking for guidance for wayfinding of basemap data or accessing basemap data with |
@bevingtona @stephhazlitt thank you both for the quick responses and advice! The example I shared maybe is a bit more focused on insets than what I will need to do. The part of it I really want to create is that base terrain layer, then layer on the boundaries of various health geographies etc. Thanks for the directions towards the data catalogue, I'll pursue that and hopefully have a positive update in the near future. |
A helpful addition to the package would be to have the basemaps from BCGW accessible through the package either at the different scales, or with an autoscale function if feasible.
The text was updated successfully, but these errors were encountered: