86smopuiM 86smopuiM - 2 months ago 13
R Question

Using leaflet with large data - ACS data for all counties in U.S

I'm plotting ACS data (counts of low-income children) for each county across the entire U.S. I don't have any markers, just a county shapefile and 6 values for each county that are in separate layers.

Unsurprisingly this is too large for browsers to handle. I've seen some similar questions here that deal with clustering, but since I have nothing to cluster I'm starting a new question.

I've tried breaking it up into 6 regional maps, but even those are too much.

Is there some way to lower the footprint, but still have all the county specific data?

I've looked at tilemill and other options for only loading the data the user is currently viewing and based on the zoom level, but I can't find any information on how to go from an R generated leaflet map to something like that. Alternatives using this route are useful as well.


You can try to simplify the polygons using the rmapshaper package and then try visualising it with mapview. The former will help get rid of 'unnecessary' polygon vertices, while the latter has dedicated functions to enable leaflet rendering of large data (ballpark around 100k features - depending on complexity).