Jeffrey Perkel / May 03 2019

London Research Landmarks

This is a copy of an R Markdown notebook originally created to accompany a Nature magazine Toolbox article on free and open-source mapping tools.

install.packages("leaflet")
library (leaflet)
# to display the Leaflet widget...
library (htmlwidgets)
options(nextjournal.display.htmlwidgetsEnabled = TRUE)
df <- read.csv(textConnection(
"Name,Lat,Long
Nature,51.533925,-0.121553
Francis Crick Institute,51.531877,-0.128767
University College London,51.524486,-0.133997
MRC Laboratory for Molecular Cell Biology,51.524435,-0.132495
King's College London,51.511573,-0.116083
Imperial College London,51.498780,-0.174888
Cambridge University,52.206960,0.115034
Oxford University,51.754843,-1.254302
Platform 9 3/4,51.532349,-0.123806
"))
# create a blank map
m <- leaflet() 

# mark points with blue circles, except Nature's offices in red...
m <- addCircleMarkers(m, lat=df$Lat, lng=df$Long, label=df$Name, 
               color = (ifelse (df$Name == "Nature", "red", "blue"))) 

# add an underlying basemap
m <- addProviderTiles(m, providers$OpenTopoMap) 

# center the view on London
m <- setView(m, -0.119,51.525, zoom = 8) 

# pull in MacroStrat tiles
m <- addTiles (m, 'https://tiles.macrostrat.org/carto/{z}/{x}/{y}.png', 
               options = tileOptions(opacity = 0.6))

# draw the map
m
sessionInfo()