Thinking Big with Maps in R
Tips on Wrangling Large Vector Data into Interactive Maps
Silvia Canelón, PhD
CANSSI Ontario Statistical Software Conference
Nov. 10, 2022
Navigation
- A table of contents for these slides can be accessed by clicking on the hamburger menu icon on the bottom left corner of the screen
- You can navigate the deck:
- Using the left/right or up/down arrow keys on your keyboard
- Clicking on the up/down controls in the bottom right corner of the screen
Static map
- A lot of lines
- Some large polygons?
- Seems like the entire county was covered by tree canopy
I needed an interactive map to take a closer look at the data
Which package to use?
leaflet
is best for datasets with <50,000 features…my tree canopy dataset had 193,418 multipolygons
leafgl
is recommended in concert with leaflet
(spoiler: it didn’t work for me)
- settled on
mapview
- Vertical strips of data missing
- Non-functional interactivity
- RStudio would crash
- VSCode was hit-or-miss
Suggestion
Simplify geometry with rmapshaper
- super complicated multipolygons
- simplifying eliminating features
Suggestion
Try the tmap package
Suggestion (WIP)
Try the rdeck package
Bonus slide!
This slide was added after the presentation to include feedback from talk attendees
- Rendering issues might come from maxing out the RAM
- To reduce the size of the dataset, one could adjust the precision because sometimes the features contain more digits than you need or can meaningfully rely on
- The mapdeck package might be another one to try. It’s powerful and sits on Mapbox which lets you pull in nice basemaps as well