Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Marker cluster in tmap

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?

like image 679
ccamara Avatar asked Oct 28 '22 23:10

ccamara


1 Answers

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

like image 179
Bjørn Kallerud Avatar answered Nov 15 '22 05:11

Bjørn Kallerud