Label a map with lead lines/call out using tmap in R

145 Views Asked by At

I am trying to produce a map using the tmap library. I want to label all areas and use lead lines to label tiny areas. I'm looking for a line of code that works like ggrepel in ggplot2 or geom_sf_label_repel in the sf library but for tmap.

Here is a sample code which shows all labels but no lead lines outside the polygons:

library(tmap)
data(World)
tm_shape(World) + tm_polygons("HPI") + tm_text("name",size=0.4)

THis is the result:

Image showing labels on the map using tm_text with tmap

There are overlapping labels that could have been placed in the white spaces with leading lines to the polygons

This is the kind of end result I hope to have where the polygon is too small to show a label correctly:

Labels outside plot area

How do I achieve this with tmap with an actual shapefile?

0

There are 0 best solutions below