Reputation: 329
I am working with tmaps and I'm plotting Colombia's map, which has a very small city (city == "San Andrés"). When I plot the map I have this:
tm_shape(mapa_municipal) +
tm_borders ()+
tm_polygons("Ganador_20181V")
I have seen in some pages that it is possible to do a zoom to that part, like this:
Does anybody knows how to do this? Thanks in advance!
Upvotes: 1
Views: 843
Reputation: 1640
That is called a mini map or auxuliar map. In tmap you can do it by creating the two maps independetly and then pasting them together with the print() function. You will have to add a viewport in the vp argument.
For more information check this tutorial: https://orlando-sabogal.github.io/SpatialAnalysis-MontevideoWorkshop2019/Notebooks/tmap-tutorial.nb.html#auxiliar-map
The code would look something like this:
MontevideoMap <- tm_shape(Montevideo) +
tm_polygons() +
tm_shape(Accidents) + tm_bubbles()
UruguayMap <- tm_shape(Uruguay) +
tm_polygons()
library(grid)
MontevideoMap
print(UruguayMap, vp = viewport(0.17, 0.8, width = 0.25, height = 0.25))
Upvotes: 2