June 2016
Beginner to intermediate
1783 pages
71h 22m
English
In this recipe, we will learn how to read and write geographic data in the form of shapefiles (.shp), using Geographical Information Systems (GIS) software created by ESRI and some other similar software.
We are going to use the maptools package for this recipe. So, let's install and load it first:
install.packages("maptools")
library(maptools)We are going to read an example shapefile provided with the maptools package and plot it:
sfdata <- readShapeSpatial(system.file("shapes/sids.shp",
package="maptools")[1], proj4string=CRS("+proj=longlat"))
plot(sfdata, col="orange", border="white", axes=TRUE)To write out the data as another shapefile, we can do:
writeSpatialShape(sfdata,"xxpoly")
Read now
Unlock full access