Albert Y. Kim
Friday 2016/4/8
Today we will create interactive maps.
OpenStreetMap (OSM) is a collaborative project to create a free editable map of the world. This is crowd-sourced open source alternative to Google Maps. For example, the following institutions use it instead of Google Maps:
Leaflet is the leading open-source JavaScript library for mobile-friendly interactive maps.
Quote on their page: Leaflet doesn't try to do everything for everyone. Instead it focuses on making the basic things work perfectly.
Example: Classics Major Haley Tilt at Reed's project on Livy's Rome.
There is an R package to interface with Leaflet which simply hooks Leaflet into R: https://rstudio.github.io/leaflet/
You create a Leaflet map with these basic steps:
leaflet().addTiles, addMarkers, addPolygons) to modify the map widget.If you understand ggplot(), you can understand leaflet():
data, which can be
lat or latitudelng, long, lng, or longitudemaps package data framesp package object. See this linkThe sp package is the go-to package for vector data (as opposed to raster)
for GIS in R. Objects can be either
SpatialPointsSpatialLinesSpatialPolygonsFor example, when you load a shapefile into R using rgdal::readOGR, it is loaded
as a sp package object.