6

I am currently using tmap to create interactive maps. Since the results are quite cluttered at initial zoom (see image below), I would like to implement marker clusters.

enter image description here

I know leaflet allows using marker clusters by adding the parameter clusterOptions = markerClusterOptions() to addMarkers() or addCircleMarkers() calls (Source: https://rstudio.github.io/leaflet/markers.html) but haven't found how to achieve that using tmap.

How can I add marker clusters in tmap?

ccamara
  • 1,141
  • 1
  • 12
  • 32

1 Answers1

3

If anyone from the future is curious, tmap supports clustering by setting clustering = TRUE in tm_symbols.

library(tmap)

data(metro)
tmap_mode("view")
tm_shape(metro) + tm_dots(clustering = T)

enter image description here

ccamara
  • 1,141
  • 1
  • 12
  • 32
Bjørn Kallerud
  • 979
  • 8
  • 23
  • 1
    Thank you very much, that's what I was looking for! I could not find that parameter 8at least when I made the question some years ago) – ccamara Jul 16 '20 at 08:02