1

I have a raster and I'd like to underlie it with a basemap in tmap. In the view-mode this kind of happens automatically. But when I set it to plot-mode I really struggle to get a basemap. Anyone maybe has a pointer on where to look?

I thought about something like this:

tm_shape(raster1) + tm_raster("col1.VALUE", palette = "viridis") + 
tm_basemap("Stamen.Watercolor") + tm_tiles("Stamen.TonerLabels")
1

The rosm package can download tiles from OpenStreetMap and construct an RGB raster that you can use as the first layer in a tmap plot.

For some raster r, something like [untested precisely]:

 x <- osm.raster(r, crop=TRUE)
 tm_shape(x) + tm_rgb() + tm_shape(r) + tm_raster()

will map r over the basemap image x.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.