SlideShare a Scribd company logo
1 of 7
Demonstration of how to read and write ESRI
Shapefiles in R, including points, lines, and polygons.
Sazid Ibna Zaman
Data Manager & GIS Specialist
MEEM Project
MORU & NMCP
Requirements
 Rstudio installed
 Packages(rgdal, RColorbrewer,sp)
rgdal: Bindings for the Geospatial Data Abstraction Library
translator library for raster and vector geospatial data formats
RColorBrewer: Color brewer pallates
sp: Classes & Methods for spatial data
 Shape File
Boundary, Roadline, Community Clinic
Notes
The rgdal approaches produce Spatial DataFrame objects in R, as defined in the 'sp'
package.
read-write-shapefiles.R
R code intended as a basic demonstration of how to read and write ESRI Shapefiles in R,
including points, lines, and polygons.
Input Data
Administrative Boundary
Polygon shapefile of Ramu Upazila in Cox’s Bazar District
Community Clinic
Point shapefile of community clinic of that region
Rodeline
Line shapefile of major roads in that region
Output
* Copy of the region point, line, polygon shapefile, written out by rgdal functions.
* Map visualization .
Codes to read-write-shapefiles.R
# read in shapefiles
centroids.rg <- readOGR(".", "Ramu_CC")----Community Clinic
road.rg <- readOGR(".", "Ramu_RoadLine")----Road Line
counties.rg <- readOGR(".", "Ramu_UnBnd")----Administrative Boundary
# note that readOGR will read the .prj file if it exists
print(proj4string(counties.rg))
# set up colors:RColorBrewer
plotclr <- brewer.pal(11,"BrBG")
plotvar <-counties.rg@data$Union_NM
class <- classIntervals(plotvar)
colcode <- findColours(class, plotclr)
Codes to read-write-shapefiles.R
# generate a simple map showing all three layers
1. Plotting Administrative Boundary
plot(counties.rg, axes=TRUE, col=plotclr, border="black")
2. Showing labels
text(coordinates(counties.rg),labels=paste(plotvar),pos=1,c
ex=.5,col="white")
3. Plotting Road Lines
lines(road.rg, col="red", lwd=1.0)
4. Plotting Community Clinic
points(centroids.rg, pch=20, col="yellow",cex=1.5)
5. Title of the map
title(main="Assessing the contribution of migration to the
emergence and spread of antimalarial drug resistance in
Bangladesh")
legend("bottomright","Community Clinic of Ramu Upazila")
6. Legend of the map
legend("topleft",c("Road Line","Community Clinic"),
lwd=c(3,3),col=c("red","yellow"),title = "Legend",cex =
.75,bty = "y") # border
1
2
3
4
5
6
THANK YOU

More Related Content

Similar to Demonstration of how to read and write ESRI

TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...
TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...
TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...Debraj GuhaThakurta
 
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...Debraj GuhaThakurta
 
Weka Hertz Clock Based Weka Bits Per Second P.R.B.S Data Array Encryption A.S...
Weka Hertz Clock Based Weka Bits Per Second P.R.B.S Data Array Encryption A.S...Weka Hertz Clock Based Weka Bits Per Second P.R.B.S Data Array Encryption A.S...
Weka Hertz Clock Based Weka Bits Per Second P.R.B.S Data Array Encryption A.S...theijes
 
Neo4j Morpheus: Interweaving Documents, Tables and and Graph Data in Spark wi...
Neo4j Morpheus: Interweaving Documents, Tables and and Graph Data in Spark wi...Neo4j Morpheus: Interweaving Documents, Tables and and Graph Data in Spark wi...
Neo4j Morpheus: Interweaving Documents, Tables and and Graph Data in Spark wi...Databricks
 
EECS 214395--‐Data Structures and Data Mana.docx
EECS  214395--‐Data    Structures    and    Data   Mana.docxEECS  214395--‐Data    Structures    and    Data   Mana.docx
EECS 214395--‐Data Structures and Data Mana.docxjack60216
 
MONOGENIC SCALE SPACE BASED REGION COVARIANCE MATRIX DESCRIPTOR FOR FACE RECO...
MONOGENIC SCALE SPACE BASED REGION COVARIANCE MATRIX DESCRIPTOR FOR FACE RECO...MONOGENIC SCALE SPACE BASED REGION COVARIANCE MATRIX DESCRIPTOR FOR FACE RECO...
MONOGENIC SCALE SPACE BASED REGION COVARIANCE MATRIX DESCRIPTOR FOR FACE RECO...cscpconf
 
“ Implimentation of SD Processor Based On CRDC Algorithm ”
“ Implimentation of SD Processor Based On CRDC Algorithm ”“ Implimentation of SD Processor Based On CRDC Algorithm ”
“ Implimentation of SD Processor Based On CRDC Algorithm ”inventionjournals
 
Open Source GIS Workshop
Open Source GIS WorkshopOpen Source GIS Workshop
Open Source GIS WorkshopJason Dalton
 
Graphs in data structures are non-linear data structures made up of a finite ...
Graphs in data structures are non-linear data structures made up of a finite ...Graphs in data structures are non-linear data structures made up of a finite ...
Graphs in data structures are non-linear data structures made up of a finite ...bhargavi804095
 
IBM Insight 2015 - 1823 - Geospatial analytics with dashDB in the cloud
IBM Insight 2015 - 1823 - Geospatial analytics with dashDB in the cloudIBM Insight 2015 - 1823 - Geospatial analytics with dashDB in the cloud
IBM Insight 2015 - 1823 - Geospatial analytics with dashDB in the cloudTorsten Steinbach
 
Using R for Cyber Security Part 1
Using R for Cyber Security Part 1Using R for Cyber Security Part 1
Using R for Cyber Security Part 1Ajay Ohri
 
Graphics Standards and Algorithm
Graphics Standards and AlgorithmGraphics Standards and Algorithm
Graphics Standards and AlgorithmYatin Singh
 
Digitization and 3d modelling of a mine plan
Digitization and 3d modelling of a mine planDigitization and 3d modelling of a mine plan
Digitization and 3d modelling of a mine planSafdar Ali
 

Similar to Demonstration of how to read and write ESRI (20)

Visualization Proess
Visualization ProessVisualization Proess
Visualization Proess
 
TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...
TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...
TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...
 
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...
 
Weka Hertz Clock Based Weka Bits Per Second P.R.B.S Data Array Encryption A.S...
Weka Hertz Clock Based Weka Bits Per Second P.R.B.S Data Array Encryption A.S...Weka Hertz Clock Based Weka Bits Per Second P.R.B.S Data Array Encryption A.S...
Weka Hertz Clock Based Weka Bits Per Second P.R.B.S Data Array Encryption A.S...
 
Cad to ESRI Geodatabase Conversion
Cad to ESRI Geodatabase ConversionCad to ESRI Geodatabase Conversion
Cad to ESRI Geodatabase Conversion
 
Building a Scalable Data Science Platform with R
Building a Scalable Data Science Platform with RBuilding a Scalable Data Science Platform with R
Building a Scalable Data Science Platform with R
 
R Course Online
R Course OnlineR Course Online
R Course Online
 
Neo4j Morpheus: Interweaving Documents, Tables and and Graph Data in Spark wi...
Neo4j Morpheus: Interweaving Documents, Tables and and Graph Data in Spark wi...Neo4j Morpheus: Interweaving Documents, Tables and and Graph Data in Spark wi...
Neo4j Morpheus: Interweaving Documents, Tables and and Graph Data in Spark wi...
 
R on Hadoop
R on HadoopR on Hadoop
R on Hadoop
 
EECS 214395--‐Data Structures and Data Mana.docx
EECS  214395--‐Data    Structures    and    Data   Mana.docxEECS  214395--‐Data    Structures    and    Data   Mana.docx
EECS 214395--‐Data Structures and Data Mana.docx
 
SAS_and_R.pdf
SAS_and_R.pdfSAS_and_R.pdf
SAS_and_R.pdf
 
MONOGENIC SCALE SPACE BASED REGION COVARIANCE MATRIX DESCRIPTOR FOR FACE RECO...
MONOGENIC SCALE SPACE BASED REGION COVARIANCE MATRIX DESCRIPTOR FOR FACE RECO...MONOGENIC SCALE SPACE BASED REGION COVARIANCE MATRIX DESCRIPTOR FOR FACE RECO...
MONOGENIC SCALE SPACE BASED REGION COVARIANCE MATRIX DESCRIPTOR FOR FACE RECO...
 
“ Implimentation of SD Processor Based On CRDC Algorithm ”
“ Implimentation of SD Processor Based On CRDC Algorithm ”“ Implimentation of SD Processor Based On CRDC Algorithm ”
“ Implimentation of SD Processor Based On CRDC Algorithm ”
 
Open Source GIS Workshop
Open Source GIS WorkshopOpen Source GIS Workshop
Open Source GIS Workshop
 
Graphs in data structures are non-linear data structures made up of a finite ...
Graphs in data structures are non-linear data structures made up of a finite ...Graphs in data structures are non-linear data structures made up of a finite ...
Graphs in data structures are non-linear data structures made up of a finite ...
 
IBM Insight 2015 - 1823 - Geospatial analytics with dashDB in the cloud
IBM Insight 2015 - 1823 - Geospatial analytics with dashDB in the cloudIBM Insight 2015 - 1823 - Geospatial analytics with dashDB in the cloud
IBM Insight 2015 - 1823 - Geospatial analytics with dashDB in the cloud
 
0507036
05070360507036
0507036
 
Using R for Cyber Security Part 1
Using R for Cyber Security Part 1Using R for Cyber Security Part 1
Using R for Cyber Security Part 1
 
Graphics Standards and Algorithm
Graphics Standards and AlgorithmGraphics Standards and Algorithm
Graphics Standards and Algorithm
 
Digitization and 3d modelling of a mine plan
Digitization and 3d modelling of a mine planDigitization and 3d modelling of a mine plan
Digitization and 3d modelling of a mine plan
 

Demonstration of how to read and write ESRI

  • 1. Demonstration of how to read and write ESRI Shapefiles in R, including points, lines, and polygons. Sazid Ibna Zaman Data Manager & GIS Specialist MEEM Project MORU & NMCP
  • 2. Requirements  Rstudio installed  Packages(rgdal, RColorbrewer,sp) rgdal: Bindings for the Geospatial Data Abstraction Library translator library for raster and vector geospatial data formats RColorBrewer: Color brewer pallates sp: Classes & Methods for spatial data  Shape File Boundary, Roadline, Community Clinic Notes The rgdal approaches produce Spatial DataFrame objects in R, as defined in the 'sp' package.
  • 3. read-write-shapefiles.R R code intended as a basic demonstration of how to read and write ESRI Shapefiles in R, including points, lines, and polygons. Input Data Administrative Boundary Polygon shapefile of Ramu Upazila in Cox’s Bazar District Community Clinic Point shapefile of community clinic of that region Rodeline Line shapefile of major roads in that region Output * Copy of the region point, line, polygon shapefile, written out by rgdal functions. * Map visualization .
  • 4. Codes to read-write-shapefiles.R # read in shapefiles centroids.rg <- readOGR(".", "Ramu_CC")----Community Clinic road.rg <- readOGR(".", "Ramu_RoadLine")----Road Line counties.rg <- readOGR(".", "Ramu_UnBnd")----Administrative Boundary # note that readOGR will read the .prj file if it exists print(proj4string(counties.rg)) # set up colors:RColorBrewer plotclr <- brewer.pal(11,"BrBG") plotvar <-counties.rg@data$Union_NM class <- classIntervals(plotvar) colcode <- findColours(class, plotclr)
  • 5. Codes to read-write-shapefiles.R # generate a simple map showing all three layers 1. Plotting Administrative Boundary plot(counties.rg, axes=TRUE, col=plotclr, border="black") 2. Showing labels text(coordinates(counties.rg),labels=paste(plotvar),pos=1,c ex=.5,col="white") 3. Plotting Road Lines lines(road.rg, col="red", lwd=1.0) 4. Plotting Community Clinic points(centroids.rg, pch=20, col="yellow",cex=1.5) 5. Title of the map title(main="Assessing the contribution of migration to the emergence and spread of antimalarial drug resistance in Bangladesh") legend("bottomright","Community Clinic of Ramu Upazila") 6. Legend of the map legend("topleft",c("Road Line","Community Clinic"), lwd=c(3,3),col=c("red","yellow"),title = "Legend",cex = .75,bty = "y") # border 1 2 3 4 5 6
  • 6.