Skip to content

Instantly share code, notes, and snippets.

@portableant
Last active March 26, 2016 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save portableant/bbf693fd0957a6c653fc to your computer and use it in GitHub Desktop.
Save portableant/bbf693fd0957a6c653fc to your computer and use it in GitHub Desktop.
An R file to split shapefiles from the OS
library(foreign)
dfblocks = read.dbf('/Users/danielpett/Documents/research/osData/england/parish_region.dbf', as.is=TRUE)
unitID = unique(dfblocks$UNIT_ID)
unitID <- as.data.frame(unitID)
for (i in 1:nrow(unitID)){
id <- unitID[i, "unitID"]
strOGR = paste(
"ogr2ogr -where 'UNIT_ID = ", id, "' /Users/danielpett/Documents/research/osData/Data/ParishRegion /Users/danielpett/Documents/research/osData/england/ parish_region -nln ", id, sep=""
)
system(strOGR)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment