Created
November 17, 2012 23:18
-
-
Save dillonma/4101307 to your computer and use it in GitHub Desktop.
Use R to read the geometry and attribute data with the rgdal package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#(so you could modify the relationships as well and create a completely new shapefile) | |
library(rgdal) | |
## read "/path/to/files/filename.shp" | |
shp <- readOGR("/path/to/files/", "filename") | |
## add new attribute data (just the numbers 1 to the number of objects) | |
shp$new.att <- 1:nrow(shp) | |
## write out to a new shapefile | |
writeOGR(shp, "/path/to/files/", "filename2") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment