Skip to content

Instantly share code, notes, and snippets.

@chris-prener
Last active December 20, 2017 13:49
Show Gist options
  • Save chris-prener/bc0420ef79e928319e682e3f74d659c0 to your computer and use it in GitHub Desktop.
Save chris-prener/bc0420ef79e928319e682e3f74d659c0 to your computer and use it in GitHub Desktop.
SOC 4650 & SOC 5650 - Lecture 01 - Introduction to GIS in R
# DEPENDENCIES:
# leaflet and devtools, installed from CRAN
# stlData, installed from GitHub
# LOAD PACKAGES:
library(leaflet)
library(stlData)
# MAP 1A: MORRISSEY HALL
# use OpenStreetMap map tiles by default
leaflet() %>%
addTiles() %>%
addMarkers(lng=-90.237104, lat=38.637547, popup="Morrissey Hall")
# MAP 1B: MORRISSEY HALL
# use CartoDB's Positron map tiles
leaflet() %>%
addProviderTiles(providers$CartoDB.Positron) %>% # Add alternative map tiles
addMarkers(lng=-90.237104, lat=38.637547, popup="Morrissey Hall")
# EXPLORING DATA
# assign data to a data frame
sluData <- sluPlaces
# spreadsheet-like view of the data
View(sluData)
# overview of variables in the data frame
str(sluData)
# MAP 2: CAMPUS LANDMARKS
# use CartoDB's Positron map tiles
leaflet(data = sluData) %>%
addProviderTiles(providers$CartoDB.Positron) %>% # Add alternative map tiles
addMarkers(lng = ~lng, lat = ~lat, popup = ~name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment