16EAGLE / basemaps

A lightweight package for accessing basemaps from open sources in R 🗺️
https://jakob.schwalb-willmann.de/basemaps
GNU General Public License v3.0
57 stars 15 forks source link

Add support for custom zoom levels #16

Closed stevenbedrick closed 1 year ago

stevenbedrick commented 1 year ago

Updating .get_map() to look for an additional optional ... parameter specifying the tile zoom level, to be passed through to bbox_to_tile_grid().

Depending on the tile set one is using and the geographic extent that one is trying to map, it may be necessary to specify a different zoom level than the one that bbox_to_tile_grid() automatically decides on. This is particularly important when one is zoomed into a small geographic area; many tile sets do not go beyond zoom level 15/16, or have irregular/incomplete coverage at the highest zoom levels (I'm looking at you, Stamen/"terrain").

This is the functionality that I was asking about in #15 . :-)

16EAGLE commented 1 year ago

Thank you very much for your contribution :-) Changed the argument from zoom to custom_zoom, but thinking of elevating this to a map_* argument like map_res in the future. Also, max_tiles is not passed when zoom is specified as this can cause an error, if they do not match. For the record, thanks to your contribution, one can now run something like

basemap_magick(ext, custom_zoom = 3) #or
basemap_magick(ext, custom_zoom = 6) #and so on

or similar to change map detail.

stevenbedrick commented 1 year ago

Good catch with the max_tiles and zoom interaction, I hadn't realized that. Thank you!