How to make a map light with leaflet with many points with markers

I need to make a map with clusters that has about 30.000 points with the code like this:

leaflet(quakes) %>% addTiles() %>% addMarkers (
clusterOptions = markerClusterOptions()

however, with 30k points the html file becomes too heavy, 47 MB.
Is there a way to make the clusters with many points and have the final map more light?

I found this library: but it seems that it does not to make clusters

I see that this library you are referencing too is in pre-alpha.
So might not be too stable. But thanks for pointing this out!
Freaking sweet!

In my company where I work I had the same issue, we in some cases had to display almost 1.2 mil records.
This would simply break it, so what I made was the window of the leaflet the filter and built some validations on that. We only had specific things we could show on the 'global map'.
This was acceptable as looking at the thing in the entire view wasn't really helpful to us.

The stuff of value is on the detailed levels typically, for our use case.

Another approach we wanted to look at is doing a very basic kmeans clustering based on the view/zoom, and in that way we could condense the data. So cluster the clusters so to speak.

Hope it helps!


Thanks for the suggestion.

Indeed I solved it by clustering the data first by distance and after I plot them with leaflet.
As a reference, I clustered it with the following:


You might be interested in the mapdeck package. This gives you access to (Uber's viz framework) and mapbox (which uses vectorized geodata to render maps rather than raster images). I've messed around with it a little bit and really like it. I haven't used it in any projects so I'm not sure how it will hold up in your case, but is built for large datasets. There are some amazing examples in the gallery.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.