Data
I have a dataframe which contains 35,000 lat/lon locations. The locations have been plotted onto an interactive leaflet map.
The S
There are a couple options I can think that might help. The best would probably be to make clusters (see Marker Clusters):
addMarkers(..., clusterOptions = markerClusterOptions())
This prevents all 35 000 points from rendering at once which speeds up the loading time.
addCircles() and addCircleMarkers() seem to load quicker than addMarkers() as well if they're okay for your purposes although they're still slow with 35 000 points.
You could then do:
addCircleMarkers(..., clusterOptions = markerClusterOptions())
which should load even faster.
Update
Use leaflet.glify (devtools::install_github("tim-salabim/leaflet.glify")
)
[Now leafgl (devtools::install_github("r-spatial/leafgl")
) - see comment below.]
See leaflet.glify [Now leafgl - see comment below.]
An approach I did use recently to plot more than 100k points and worked very well:
leaflet(options = leafletOptions(preferCanvas = TRUE))
This forces leaflet
to render the map as canvas. More info here.
The map appearance keep the same, but is much faster in terms of navigation. I didn't try leaflet.glify
yet, but it seems to be a good solution to plot thousand points using leaflet
package.