SlideShare a Scribd company logo
Prepared by Volkan OBAN
Spatial data and Maps in R: Using R as
a GIS
Reference: https://pakillo.github.io/R-GIS-tutorial/
Basic packages
library(sp) # classes for spatial data
library(raster) # grids, rasters
library(rasterVis) # raster visualization
library(maptools)
library(rgeos)
library(dismo)
library(googleVis)
library(rworldmap)
library(RgoogleMaps)
library(dismo)
mycountry <- gmap("Turkey")
plot(mycountry)
>mycountry <- gmap("Turkey", type = "satellite")
> plot(mycountry)
>mycountry <- gmap("Turkey", type = "satellite",exp=3)
> plot(mycountry)
library(RgoogleMaps)
> newmap <- GetMap(center = c(41.112185,29.019965), zoom = 10, destfile = "new
map.png",
+ maptype = "satellite")
Izmir
library(RgoogleMaps)
newmap <- GetMap(center = c(38.423734,27.142826), zoom = 10, destfile = "newm
ap.png",
+ maptype = "satellite")
İstanbul Boğazı-Bosphorus:
newmap1 <- GetMap(center = c(41.046018,29.033891), zoom = 10, destfile = "n
ewmap1.png", maptype = "satellite")
> tmin <- getData("worldclim", var = "tmin", res = 10) # this will downloa
d
> # global data on minimum temperature at 10' resolution
> tmin1 <- raster(paste(getwd(), "/wc10/tmin1.bil", sep = "")) # Tmin for
January
> fromDisk(tmin1)
[1] TRUE
> tmin1 <- tmin1/10 # Worldclim temperature data come in decimal degrees
> tmin1
class : RasterLayer
dimensions : 900, 2160, 1944000 (nrow, ncol, ncell)
resolution : 0.1666667, 0.1666667 (x, y)
extent : -180, 180, -60, 90 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs
data source : in memory
names : tmin1
values : -54.7, 26.6 (min, max)
> plot(tmin1)
> library(gtools)
> file.remove(paste(getwd(), "/wc10/", "tmin_10m_bil.zip", sep = ""))
[1] FALSE
> list.ras <- mixedsort(list.files(paste(getwd(), "/wc10/", sep = ""), full
.names = T,
+ pattern = ".bil"))
> list.ras # I have just collected a list of the files containing monthly
temperature values
list.ras <- mixedsort(list.files(paste(getwd(), "/wc10/", sep = ""), full.names =
T, pattern = ".bil")) list.ras # I have just collected a list of the files
containing monthly temperature values
>tmin.all <- stack(list.ras)
> tmin.all
class : RasterStack
dimensions : 900, 2160, 1944000, 12 (nrow, ncol, ncell, nlayers)
resolution : 0.1666667, 0.1666667 (x, y)
extent : -180, 180, -60, 90 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs
names : tmin1, tmin2, tmin3, tmin4, tmin5, tmin6, tmin7, tmin8, tmin9
, tmin10, tmin11, tmin12
min values : -547, -525, -468, -379, -225, -170, -171, -178, -192
, -302, -449, -522
max values : 266, 273, 277, 283, 295, 312, 311, 312, 300
, 268, 267, 268
> tmin.all <- tmin.all/10
> plot(tmin.all)
> elevation <- getData("alt", country = "Turkey")
> x <- terrain(elevation, opt = c("slope", "aspect"), unit = "degrees")
> plot(x)
slope <- terrain(elevation, opt = "slope")
aspect <- terrain(elevation, opt = "aspect") hill <- hillShade(slope, aspect, 40, 270)
plot(hill, col = grey(0:100/100), legend = FALSE, main = "Türkiye")
plot(elevation, col = rainbow(25, alpha = 0.35), add = TRUE)
> library(ggmap)
> library(RgoogleMaps)
> mapImageData1 <- get_map(location = c(lon =29.019442, lat =41.103783),col
or = "color",source = "google",maptype = "satellite",zoom = 17)
>
> ggmap(mapImageData1,extent = "device", ylab = "Latitude",xlab = "Longitud
e")
İTÜ (Istanbul Technical University)

More Related Content

What's hot (19)

PDF
The Weather of the Century Part 3: Visualization
MongoDB
 
KEY
Dtsn devnest9
Angus Fox
 
PDF
Semantic search within Earth Observation products databases based on automati...
Gasperi Jerome
 
PDF
Webinar: Secrets of ClickHouse Query Performance, by Robert Hodges
Altinity Ltd
 
PDF
Three Functional Programming Technologies for Big Data
Dynamical Software, Inc.
 
PPTX
Advanced R Graphics
DataminingTools Inc
 
PPTX
La R Users Group Survey Of R Graphics
guest43ed8709
 
PDF
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
Altinity Ltd
 
RTF
Sorter
Thomas Knudstrup
 
PDF
Coq for ML users
tmiya
 
PPTX
The Weather of the Century Part 2: High Performance
MongoDB
 
PDF
Data warehouse or conventional database: Which is right for you?
Data Con LA
 
PPT
Bayesian learning
EngReads
 
PDF
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
InfluxData
 
PPT
Python Coding Examples for Drive Time Analysis
Wisconsin Land Information Association
 
PPTX
GeoTuple a Framework for Web Based Geo-Analytics with R and PostGIS
Roland Hansson
 
PPTX
Ordered Record Collection
Hadoop User Group
 
PDF
Team ElectricGo: 2013 Apache Cassandra Hackathon at McGill University
DataStax Academy
 
PDF
OTTER 2017-12-03
Ruo Ando
 
The Weather of the Century Part 3: Visualization
MongoDB
 
Dtsn devnest9
Angus Fox
 
Semantic search within Earth Observation products databases based on automati...
Gasperi Jerome
 
Webinar: Secrets of ClickHouse Query Performance, by Robert Hodges
Altinity Ltd
 
Three Functional Programming Technologies for Big Data
Dynamical Software, Inc.
 
Advanced R Graphics
DataminingTools Inc
 
La R Users Group Survey Of R Graphics
guest43ed8709
 
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
Altinity Ltd
 
Coq for ML users
tmiya
 
The Weather of the Century Part 2: High Performance
MongoDB
 
Data warehouse or conventional database: Which is right for you?
Data Con LA
 
Bayesian learning
EngReads
 
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
InfluxData
 
Python Coding Examples for Drive Time Analysis
Wisconsin Land Information Association
 
GeoTuple a Framework for Web Based Geo-Analytics with R and PostGIS
Roland Hansson
 
Ordered Record Collection
Hadoop User Group
 
Team ElectricGo: 2013 Apache Cassandra Hackathon at McGill University
DataStax Academy
 
OTTER 2017-12-03
Ruo Ando
 

Similar to R Data Visualization-Spatial data and Maps in R: Using R as a GIS (20)

PDF
Spatial Analysis with R - the Good, the Bad, and the Pretty
Noam Ross
 
ODP
Geospatial Data in R
Barry Rowlingson
 
PDF
sexy maps comes to R - ggplot+ google maps= ggmap #rstats
Ajay Ohri
 
PDF
Spatial visualization with ggplot2
Joaquim Silva
 
PPTX
R spatial presentation
Todd Barr
 
PPTX
Using R to Visualize Spatial Data: R as GIS - Guy Lansley
Guy Lansley
 
PDF
Climate data in r with the raster package
Alberto Labarga
 
DOCX
Ggmap Packages in R
Dr. Volkan OBAN
 
PDF
Geo Spatial Plot using R
Rupak Roy
 
PDF
The Matsu Project - Open Source Software for Processing Satellite Imagery Data
Robert Grossman
 
PDF
Catalog on the fly satellite images
Luiz Motta
 
PDF
Download full ebook of Datacamp Ggplot2 Cheatsheet Itebooks instant download pdf
miatalafeer
 
PPT
R Spatial Analysis using SP
tjagger
 
PDF
Big datacourse
Massimiliano Ruocco
 
PDF
Spatial_Data_Analysis_with_open_source_softwares[1]
Joachim Nkendeys
 
PDF
Eurostat cheatsheet
Dieudonne Nahigombeye
 
PDF
10. R getting spatial
ExternalEvents
 
Spatial Analysis with R - the Good, the Bad, and the Pretty
Noam Ross
 
Geospatial Data in R
Barry Rowlingson
 
sexy maps comes to R - ggplot+ google maps= ggmap #rstats
Ajay Ohri
 
Spatial visualization with ggplot2
Joaquim Silva
 
R spatial presentation
Todd Barr
 
Using R to Visualize Spatial Data: R as GIS - Guy Lansley
Guy Lansley
 
Climate data in r with the raster package
Alberto Labarga
 
Ggmap Packages in R
Dr. Volkan OBAN
 
Geo Spatial Plot using R
Rupak Roy
 
The Matsu Project - Open Source Software for Processing Satellite Imagery Data
Robert Grossman
 
Catalog on the fly satellite images
Luiz Motta
 
Download full ebook of Datacamp Ggplot2 Cheatsheet Itebooks instant download pdf
miatalafeer
 
R Spatial Analysis using SP
tjagger
 
Big datacourse
Massimiliano Ruocco
 
Spatial_Data_Analysis_with_open_source_softwares[1]
Joachim Nkendeys
 
Eurostat cheatsheet
Dieudonne Nahigombeye
 
10. R getting spatial
ExternalEvents
 
Ad

More from Dr. Volkan OBAN (20)

PDF
Conference Paper:IMAGE PROCESSING AND OBJECT DETECTION APPLICATION: INSURANCE...
Dr. Volkan OBAN
 
PDF
Covid19py Python Package - Example
Dr. Volkan OBAN
 
PDF
Object detection with Python
Dr. Volkan OBAN
 
PDF
Python - Rastgele Orman(Random Forest) Parametreleri
Dr. Volkan OBAN
 
DOCX
Linear Programming wi̇th R - Examples
Dr. Volkan OBAN
 
DOCX
"optrees" package in R and examples.(optrees:finds optimal trees in weighted ...
Dr. Volkan OBAN
 
DOCX
k-means Clustering in Python
Dr. Volkan OBAN
 
DOCX
Naive Bayes Example using R
Dr. Volkan OBAN
 
DOCX
R forecasting Example
Dr. Volkan OBAN
 
DOCX
k-means Clustering and Custergram with R
Dr. Volkan OBAN
 
PDF
Data Science and its Relationship to Big Data and Data-Driven Decision Making
Dr. Volkan OBAN
 
DOCX
Data Visualization with R.ggplot2 and its extensions examples.
Dr. Volkan OBAN
 
PDF
Scikit-learn Cheatsheet-Python
Dr. Volkan OBAN
 
PDF
Python Pandas for Data Science cheatsheet
Dr. Volkan OBAN
 
PDF
Pandas,scipy,numpy cheatsheet
Dr. Volkan OBAN
 
PPTX
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
PPTX
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
DOCX
R-ggplot2 package Examples
Dr. Volkan OBAN
 
DOCX
R Machine Learning packages( generally used)
Dr. Volkan OBAN
 
DOCX
treemap package in R and examples.
Dr. Volkan OBAN
 
Conference Paper:IMAGE PROCESSING AND OBJECT DETECTION APPLICATION: INSURANCE...
Dr. Volkan OBAN
 
Covid19py Python Package - Example
Dr. Volkan OBAN
 
Object detection with Python
Dr. Volkan OBAN
 
Python - Rastgele Orman(Random Forest) Parametreleri
Dr. Volkan OBAN
 
Linear Programming wi̇th R - Examples
Dr. Volkan OBAN
 
"optrees" package in R and examples.(optrees:finds optimal trees in weighted ...
Dr. Volkan OBAN
 
k-means Clustering in Python
Dr. Volkan OBAN
 
Naive Bayes Example using R
Dr. Volkan OBAN
 
R forecasting Example
Dr. Volkan OBAN
 
k-means Clustering and Custergram with R
Dr. Volkan OBAN
 
Data Science and its Relationship to Big Data and Data-Driven Decision Making
Dr. Volkan OBAN
 
Data Visualization with R.ggplot2 and its extensions examples.
Dr. Volkan OBAN
 
Scikit-learn Cheatsheet-Python
Dr. Volkan OBAN
 
Python Pandas for Data Science cheatsheet
Dr. Volkan OBAN
 
Pandas,scipy,numpy cheatsheet
Dr. Volkan OBAN
 
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
R-ggplot2 package Examples
Dr. Volkan OBAN
 
R Machine Learning packages( generally used)
Dr. Volkan OBAN
 
treemap package in R and examples.
Dr. Volkan OBAN
 
Ad

Recently uploaded (20)

PPTX
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
PDF
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
PPTX
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
PDF
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna
 
PDF
How to Connect Your On-Premises Site to AWS Using Site-to-Site VPN.pdf
Tamanna
 
PPTX
AI Presentation Tool Pitch Deck Presentation.pptx
ShyamPanthavoor1
 
PPTX
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
PPTX
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
PDF
OPPOTUS - Malaysias on Malaysia 1Q2025.pdf
Oppotus
 
PDF
AUDITABILITY & COMPLIANCE OF AI SYSTEMS IN HEALTHCARE
GAHI Youssef
 
PDF
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
PPTX
apidays Helsinki & North 2025 - Vero APIs - Experiences of API development in...
apidays
 
PPTX
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
PDF
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
PPTX
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PDF
Data Chunking Strategies for RAG in 2025.pdf
Tamanna
 
PPTX
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
PDF
R Cookbook - Processing and Manipulating Geological spatial data with R.pdf
OtnielSimopiaref2
 
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna
 
How to Connect Your On-Premises Site to AWS Using Site-to-Site VPN.pdf
Tamanna
 
AI Presentation Tool Pitch Deck Presentation.pptx
ShyamPanthavoor1
 
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
OPPOTUS - Malaysias on Malaysia 1Q2025.pdf
Oppotus
 
AUDITABILITY & COMPLIANCE OF AI SYSTEMS IN HEALTHCARE
GAHI Youssef
 
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
apidays Helsinki & North 2025 - Vero APIs - Experiences of API development in...
apidays
 
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
Data Chunking Strategies for RAG in 2025.pdf
Tamanna
 
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
R Cookbook - Processing and Manipulating Geological spatial data with R.pdf
OtnielSimopiaref2
 

R Data Visualization-Spatial data and Maps in R: Using R as a GIS

  • 1. Prepared by Volkan OBAN Spatial data and Maps in R: Using R as a GIS Reference: https://pakillo.github.io/R-GIS-tutorial/ Basic packages library(sp) # classes for spatial data library(raster) # grids, rasters library(rasterVis) # raster visualization library(maptools) library(rgeos) library(dismo) library(googleVis) library(rworldmap) library(RgoogleMaps)
  • 3. >mycountry <- gmap("Turkey", type = "satellite") > plot(mycountry)
  • 4. >mycountry <- gmap("Turkey", type = "satellite",exp=3) > plot(mycountry)
  • 5. library(RgoogleMaps) > newmap <- GetMap(center = c(41.112185,29.019965), zoom = 10, destfile = "new map.png", + maptype = "satellite")
  • 6. Izmir library(RgoogleMaps) newmap <- GetMap(center = c(38.423734,27.142826), zoom = 10, destfile = "newm ap.png", + maptype = "satellite")
  • 7. İstanbul Boğazı-Bosphorus: newmap1 <- GetMap(center = c(41.046018,29.033891), zoom = 10, destfile = "n ewmap1.png", maptype = "satellite")
  • 8. > tmin <- getData("worldclim", var = "tmin", res = 10) # this will downloa d > # global data on minimum temperature at 10' resolution > tmin1 <- raster(paste(getwd(), "/wc10/tmin1.bil", sep = "")) # Tmin for January > fromDisk(tmin1) [1] TRUE > tmin1 <- tmin1/10 # Worldclim temperature data come in decimal degrees > tmin1 class : RasterLayer dimensions : 900, 2160, 1944000 (nrow, ncol, ncell) resolution : 0.1666667, 0.1666667 (x, y) extent : -180, 180, -60, 90 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs data source : in memory names : tmin1 values : -54.7, 26.6 (min, max) > plot(tmin1)
  • 9. > library(gtools) > file.remove(paste(getwd(), "/wc10/", "tmin_10m_bil.zip", sep = "")) [1] FALSE > list.ras <- mixedsort(list.files(paste(getwd(), "/wc10/", sep = ""), full .names = T, + pattern = ".bil")) > list.ras # I have just collected a list of the files containing monthly temperature values list.ras <- mixedsort(list.files(paste(getwd(), "/wc10/", sep = ""), full.names = T, pattern = ".bil")) list.ras # I have just collected a list of the files containing monthly temperature values >tmin.all <- stack(list.ras) > tmin.all class : RasterStack dimensions : 900, 2160, 1944000, 12 (nrow, ncol, ncell, nlayers) resolution : 0.1666667, 0.1666667 (x, y) extent : -180, 180, -60, 90 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs names : tmin1, tmin2, tmin3, tmin4, tmin5, tmin6, tmin7, tmin8, tmin9 , tmin10, tmin11, tmin12
  • 10. min values : -547, -525, -468, -379, -225, -170, -171, -178, -192 , -302, -449, -522 max values : 266, 273, 277, 283, 295, 312, 311, 312, 300 , 268, 267, 268 > tmin.all <- tmin.all/10 > plot(tmin.all)
  • 11. > elevation <- getData("alt", country = "Turkey") > x <- terrain(elevation, opt = c("slope", "aspect"), unit = "degrees") > plot(x)
  • 12. slope <- terrain(elevation, opt = "slope") aspect <- terrain(elevation, opt = "aspect") hill <- hillShade(slope, aspect, 40, 270) plot(hill, col = grey(0:100/100), legend = FALSE, main = "Türkiye") plot(elevation, col = rainbow(25, alpha = 0.35), add = TRUE)
  • 13. > library(ggmap) > library(RgoogleMaps) > mapImageData1 <- get_map(location = c(lon =29.019442, lat =41.103783),col or = "color",source = "google",maptype = "satellite",zoom = 17) > > ggmap(mapImageData1,extent = "device", ylab = "Latitude",xlab = "Longitud e") İTÜ (Istanbul Technical University)