Leaflet R Package - An introduction
Developed by Vladimir Agafonkin, "Leaflet" is a Javascript library for interactive maps.
The leaflet package in R is developed by RStudio team and is a wrapper for Javascript library Leaflet. It allows to make interactive web maps right from the R console. It integrates easily with R Markdown, R Shiny apps.
We start with creating a map widget using the leaflet() function, supply the data of interest, add methods or layers (features) on map widget and done!!!
- Data types supported :
- Dataframe or matrix containing latitude & longitude variables
- Data from the sp package: any of the spatial classes provided by sp
- Data from maps package: any of the maps from the map database
- JSON format: add your data in GeoJSON or TopoJSON format via jsonlite
- Features or layers that could be added :
- Panning and Zooming (comes default with leaflet() but levels could be adjusted)
- Map tiles (Default is OSM but other 3rd party base map available)
- Markers (Map markers, circle markers, or customized markers)
- Popups/labels/Images (onclick popus, or mouse over labels)
- Polygons / Rectangles / Lines
- GeoJSON / TopoJSON
- Raster Images
- Legends
- Layer Groups and Layer Control