SlideShare a Scribd company logo
R spatial presentation
Who are you?
Todd Barr
Spatial Statistician/GeoData Sherpa
R spatial presentation
R spatial presentation
R spatial presentation
R spatial presentation
R spatial presentation
R spatial presentation
R spatial presentation
Outline
• Spatial Libraries
• GeoData
• Spatial Joins/Cholorpleth Map
• Heat Map
BackgRound on R
• Developed in the 90s base on a Proprietary Statistical Language called
‘S’ and S-Plus, by Statisticians for Statistical Models.
Advantages of R - Spatial
• Command Line Interface
• Customizable Graphics
• Native Spatial Data
• Easily Extensible through Libraries
• Many Tools to Munge Data, both Spatial and Tabular
• Native Modeling and Analysis in Code
• Levels the Playing Field
Disadvantages of R - Spatial
• Steepish Learning Curve (even with Rstudio)
• Difficult to Visualize Data (lack of interactive canvas in Rstudio)
• Difficult to Dynamically Select things from a map
• Single Core Processing (can be augmented with Libraries)
• Libraries with overlapping functionalities
R in “Traditional” Spatial/GIS
• Spatial
• ArcGIS
• R interface supported by ESRI Open Project “R Bridge”
• QGIS
• Imbedded a Functionality
• Use R in the Native Script Editor
• GeoDA
• Native R code, and functionality
• gvSIG
• R plugin to allow
R in “Traditional” Spatial/GIS
•Kinda Spatial
•Tableau
•Spotfire
R in “Traditional” Spatial/GIS
• Capable of GeoAnalytics
• SAS
• SPSS
R spatial presentation
R spatial presentation
R spatial presentation
0
10
20
30
40
50
60
70
80
2009 2010 2011 2012 2013 2014 2015 2016 2017
R Spatial Libraries
Libraries we’re Going to Focus On
• ggplot2 - Library for the declarative generation of graphics
• ggmap - Library for draping data over a Google, or Statman Basemap
• maps - displays data as maps, also contains Spatial Data
• mapdata - More Map data, extends maps
• rgdal - Access to the Geospatial Data Abstraction Library (GDAL). Creates
the ability to read datatypes and change projections
• maptools - library for building and manipulating spatial information
• rgeos - geometry operations
• Cairo - high quality graphic formats for export
• scales - assists in determining best place for breaks
R spatial presentation
R spatial presentation
R spatial presentation
R spatial presentation
What is Spatial Data
• Two Cataglories
• Vector
• Point / Multipoint
• Line/Multiline
• Polygon/Multipolygon
• Raster
• It’s a matrix of pixels and each pixel has numeric attributes
• Imagery
• Some generated graphics
Geospatial Data Formats
•Data within R packages – map, mapdata or oz
•Files or Endpoints with Latitude and Longitude attributes (just Points)
•Shapefiles
•Geopackage/geoJSON/GML
•Google or other cloud-based mapping api's
Warming up – A Simple Map
>library(maps)
>library(mapdata)
>map(“worldHires”, “Mexico”, xlim=c(-118.4, -
86.7),ylin=c(14.5321,32.71865), col=“purple”, fill=TRUE)
R spatial presentation
Cooling Off – Another Simple Map
>library(maps)
>library(mapdata)
>map(“worldHires”,”Canada”, xilm=c(-141,-53),ylim=c(40,85), col=“red”,
fill=TRUE)
R spatial presentation
Cooling Off – Fixed Zoom In
>library(maps)
>library(mapdata)
>map(“worldHires”,”Canada”, xlim=c(-140,-110),ylim=c(48.64),
col=“red”, fill=TRUE)
R spatial presentation
map meet ggplot2
>co <- map(“county”,”colorado”, plot=FALSE, fill=TRUE)
Map meet ggplot2
>head(co)
R spatial presentation
map and ggplot2
>library(ggplot3)
>head(fortify(co))
Maps and ggplot2
map and ggplot2
>ggplot(co,aes(long, lat)) +
>geom_polygon(aes(group=group), color=“yellow”)
R spatial presentation
maps and ggplot2
>ggplot(co,aes(long, lat)) +
>geom_polygon(aes(group=group), color=“yellow”, fill=“blue”)
R spatial presentation
ggplot and shapefiles and choropleths
>library(ggplot2)
>library(maptools)
>library(rgeos)
>library(ggmap)
>library(scales)
>library(RColorBrewer)
ggplot and shapefiles and choropleths
>setwd(“$Folder_here”)
>co.shp<-readShapeSpatial(“ACS1014_county.shp”)
>class(co.shp)
>names(co.shp)
ggplot and shapefiles and choropleths
>print(co.shp$GEOID)
>print(co.shp$NAME)
ggplot and shapefiles and choropleths
>age_40<-data.frame(NAME_CO=co.shp$NAME, id=co.shp$COUNTYFP,
prevalence=co.shp$age_40_49)
>combine<-fortify(co.shp,region=“COUNTYFP”)
>head(combine)
R spatial presentation
ggplot and shapefiles and choropleths
>merge.shp<-merge(combine, age_40, by=“id”, all.x=TRUE)
>final_join<-merge.shp[order(merge.shp$order),]
ggplot and shapefiles and choropleths
>ggplot() +
+geom_polygon(data=final_join, aes(x=long, y=lat,group=group,
fill=prevalence),color=“black”, size=0.25) +
+coord_map()
R spatial presentation
ggplot and shapefiles and choropleths
>ggplot() +
+ geom_polygon(data=final_join, aes(x=long, y=lat, group=group,
fill=prevalence), color=“black”, size=0.25) +
+ coord_map +
+ scale_fill_distiller(name=“Population”, palette=“YlGn”,
breaks=pretty_breaks(n=5)) +
+ theme_nothing(legend=TRUE) +
+ labs(title=“40-49 year olds by County)
R spatial presentation
R spatial presentation
Heat Map
>library(ggplot2)
>library(ggmap)
Heat Map
>co_fm<-read.csv(path_to_fm_xy.csv)
>head(co_fm)
Heat Map
>co_map<-get_map(location=“Colorado”, maptype=“satellite/roadmap”,
zoom=7)
Heat Map
>ggmap(co_map, extent=“device) +
+ geom_point(aes(x=long, y=lat), color=“red”, alpha=.1, size=2,
data=co_fm)
R spatial presentation
Heat Map 2.0
>ggmap(co_map, extent = "device") +
Heat Map 2.0
+ geom_density2d(data = co_fm,aes(x = long, y = lat), size = 0.3) +
Heat Map 2.0
+ stat_density2d(data =co_fm,
aes(x = lon, y = lat, fill = ..level.., alpha = ..level..), size = 0.01,
bins = 16, geom = "polygon") +
Heat Map 2.0
+ scale_fill_gradient(low = "green", high = "red") +
Heat Map 2.0
+ scale_alpha(range = c(0, 0.3), guide = FALSE)
R spatial presentation
R spatial presentation
http://rspatial.org/
https://cran.r-project.org/web/views/Spatial.html
https://www.datacamp.com/courses/working-with-geospatial-data-in-r
Resources

More Related Content

What's hot (20)

PPT
Applications of GIS to Logistics and Transportation
sorbi
 
PPTX
Gis functions
Shah Naseer
 
PPTX
Introduction to ArcGIS
Kate Dougherty
 
PDF
DIGITAL IMAGE PROCESSING - LECTURE NOTES
Ezhilya venkat
 
PDF
Remote sensing Question Bank.pdf
RAMKRISHNAMAHATO5
 
PPTX
Introduction to GIS
Obaidur Rahaman Ovi
 
PDF
Digital Image Processing and gis software systems
Nirmal Kumar
 
PDF
Basic remote sensing and gis
SatGur Masters Academy
 
PPTX
History of gis
Ehtisham Wajid
 
PDF
How to download Sentinel 2 satellite data
Gowtham Gollapalli
 
PPTX
Remote Sensing: Change Detection
Kamlesh Kumar
 
PPTX
Vector data model
PRAMODA G
 
PPTX
Remote Sensing: Principal Component Analysis
Kamlesh Kumar
 
PDF
Fundamentals of GIS
Pallab Jana
 
PPT
Free open source gis
Ashok Peddi
 
PPT
Global warming ppt
dineshgarhwal77
 
PPTX
Data models in geographical information system(GIS)
PRAMODA G
 
PPT
Digital image processing
Dhaval Jalalpara
 
PPTX
Agriculture &amp; gis
Shanake Dissanayake
 
Applications of GIS to Logistics and Transportation
sorbi
 
Gis functions
Shah Naseer
 
Introduction to ArcGIS
Kate Dougherty
 
DIGITAL IMAGE PROCESSING - LECTURE NOTES
Ezhilya venkat
 
Remote sensing Question Bank.pdf
RAMKRISHNAMAHATO5
 
Introduction to GIS
Obaidur Rahaman Ovi
 
Digital Image Processing and gis software systems
Nirmal Kumar
 
Basic remote sensing and gis
SatGur Masters Academy
 
History of gis
Ehtisham Wajid
 
How to download Sentinel 2 satellite data
Gowtham Gollapalli
 
Remote Sensing: Change Detection
Kamlesh Kumar
 
Vector data model
PRAMODA G
 
Remote Sensing: Principal Component Analysis
Kamlesh Kumar
 
Fundamentals of GIS
Pallab Jana
 
Free open source gis
Ashok Peddi
 
Global warming ppt
dineshgarhwal77
 
Data models in geographical information system(GIS)
PRAMODA G
 
Digital image processing
Dhaval Jalalpara
 
Agriculture &amp; gis
Shanake Dissanayake
 

Similar to R spatial presentation (20)

PDF
Essentials of R
ExternalEvents
 
PPT
Askayworkshop
sconnin
 
PPTX
Day 6 - PostGIS
Barry Jones
 
PDF
Arc gis desktop_and_geoprocessing
Esri
 
PPTX
Using R to Visualize Spatial Data: R as GIS - Guy Lansley
Guy Lansley
 
PPTX
Plugins in QGIS and its uses
Mayuresh Padalkar
 
PPTX
Topic basic gis session 1
Kerwin Jay Condor
 
PPTX
Geographic Information System for Egyptian Railway System(GIS)
Ismail El Gayar
 
PPTX
Gis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal Ogudah
Michael Kimathi
 
PPTX
Compelling Cartography with ArcGIS
Aileen Buckley
 
PPTX
Mobile LBS
Jaak Laineste
 
KEY
Drupal mapping
Lev Tsypin
 
PDF
Thorny Path to the Large Scale Graph Processing, Алексей Зиновьев (Тамтэк)
Ontico
 
PDF
Thorny path to the Large-Scale Graph Processing (Highload++, 2014)
Alexey Zinoviev
 
PDF
Maps4Finland 28.8.2012, Pekka Sarkola
Apps4Finland
 
PDF
Maps4 finland 28.8.2012, pekka sarkola
Olli Rinne
 
PPTX
2017 GIS in Education Track: Sharing Historical Maps and Atlases in Web Apps
GIS in the Rockies
 
PDF
Introduction to MapReduce & hadoop
Colin Su
 
PPT
GIS_Whirlwind_Tour.ppt
GodwinKingNyamador
 
PPT
GIS_Whirlwind_Tour.ppt
safayetmim1
 
Essentials of R
ExternalEvents
 
Askayworkshop
sconnin
 
Day 6 - PostGIS
Barry Jones
 
Arc gis desktop_and_geoprocessing
Esri
 
Using R to Visualize Spatial Data: R as GIS - Guy Lansley
Guy Lansley
 
Plugins in QGIS and its uses
Mayuresh Padalkar
 
Topic basic gis session 1
Kerwin Jay Condor
 
Geographic Information System for Egyptian Railway System(GIS)
Ismail El Gayar
 
Gis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal Ogudah
Michael Kimathi
 
Compelling Cartography with ArcGIS
Aileen Buckley
 
Mobile LBS
Jaak Laineste
 
Drupal mapping
Lev Tsypin
 
Thorny Path to the Large Scale Graph Processing, Алексей Зиновьев (Тамтэк)
Ontico
 
Thorny path to the Large-Scale Graph Processing (Highload++, 2014)
Alexey Zinoviev
 
Maps4Finland 28.8.2012, Pekka Sarkola
Apps4Finland
 
Maps4 finland 28.8.2012, pekka sarkola
Olli Rinne
 
2017 GIS in Education Track: Sharing Historical Maps and Atlases in Web Apps
GIS in the Rockies
 
Introduction to MapReduce & hadoop
Colin Su
 
GIS_Whirlwind_Tour.ppt
GodwinKingNyamador
 
GIS_Whirlwind_Tour.ppt
safayetmim1
 
Ad

More from Todd Barr (14)

PPTX
Authentic_Leadership.pptx
Todd Barr
 
PPTX
The Core of Geospatial
Todd Barr
 
PDF
Imposterism
Todd Barr
 
PDF
The geography of geospatial
Todd Barr
 
PPTX
Tb geo dev_presentation_nov_5
Todd Barr
 
PPTX
FOSS4G 2017 Spatial Sql for Rookies
Todd Barr
 
PPTX
Workshops
Todd Barr
 
PPTX
De vsummit sessions
Todd Barr
 
PPTX
Geo am prezzie
Todd Barr
 
PPTX
PostGIS and Spatial SQL
Todd Barr
 
PPTX
Staph
Todd Barr
 
PPTX
Ambient Geographic Information and biosurveilance todd barr
Todd Barr
 
PDF
GEOPLATFORM IDIQ Released Early to Contractor
Todd Barr
 
PPTX
Jiee Geospatial Intergration Esri Uc
Todd Barr
 
Authentic_Leadership.pptx
Todd Barr
 
The Core of Geospatial
Todd Barr
 
Imposterism
Todd Barr
 
The geography of geospatial
Todd Barr
 
Tb geo dev_presentation_nov_5
Todd Barr
 
FOSS4G 2017 Spatial Sql for Rookies
Todd Barr
 
Workshops
Todd Barr
 
De vsummit sessions
Todd Barr
 
Geo am prezzie
Todd Barr
 
PostGIS and Spatial SQL
Todd Barr
 
Staph
Todd Barr
 
Ambient Geographic Information and biosurveilance todd barr
Todd Barr
 
GEOPLATFORM IDIQ Released Early to Contractor
Todd Barr
 
Jiee Geospatial Intergration Esri Uc
Todd Barr
 
Ad

Recently uploaded (20)

PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PPTX
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
PPT
AI Future trends and opportunities_oct7v1.ppt
SHIKHAKMEHTA
 
PPTX
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
PDF
How to Connect Your On-Premises Site to AWS Using Site-to-Site VPN.pdf
Tamanna
 
PPTX
ER_Model_with_Diagrams_Presentation.pptx
dharaadhvaryu1992
 
PDF
R Cookbook - Processing and Manipulating Geological spatial data with R.pdf
OtnielSimopiaref2
 
PDF
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
PDF
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
PPTX
Module-5-Measures-of-Central-Tendency-Grouped-Data-1.pptx
lacsonjhoma0407
 
PDF
Web Scraping with Google Gemini 2.0 .pdf
Tamanna
 
PPTX
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
PDF
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
apidays
 
PDF
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PDF
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
PPTX
apidays Helsinki & North 2025 - Vero APIs - Experiences of API development in...
apidays
 
PPTX
Exploring Multilingual Embeddings for Italian Semantic Search: A Pretrained a...
Sease
 
PPTX
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
PPTX
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
AI Future trends and opportunities_oct7v1.ppt
SHIKHAKMEHTA
 
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
How to Connect Your On-Premises Site to AWS Using Site-to-Site VPN.pdf
Tamanna
 
ER_Model_with_Diagrams_Presentation.pptx
dharaadhvaryu1992
 
R Cookbook - Processing and Manipulating Geological spatial data with R.pdf
OtnielSimopiaref2
 
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
Module-5-Measures-of-Central-Tendency-Grouped-Data-1.pptx
lacsonjhoma0407
 
Web Scraping with Google Gemini 2.0 .pdf
Tamanna
 
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
apidays
 
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
apidays Helsinki & North 2025 - Vero APIs - Experiences of API development in...
apidays
 
Exploring Multilingual Embeddings for Italian Semantic Search: A Pretrained a...
Sease
 
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 

R spatial presentation