| importBardShape {BARD} | R Documentation |
These are convenience functions to read and write BARD data as ESRI shapefiles.
For a faster method to store these in native form see readBardImage
exportBardShape(plan, filen, id = "BARDPlanID", gal = paste(filen, ".GAL", sep = "")) importBardShape(filen, id="BARDPlanID", gal=paste(filen,".GAL",sep=""), wantplan=FALSE)
filen |
Name (and path to) file to be read or written |
id |
name of polygon block (NOT plan) id variable |
plan |
Plan assignment |
wantplan |
whether to extract embedded BARD plan from shapefile |
gal |
GAL style contiguity list. Contiguity list will be regenerated if not supplied, but this is slow. |
Read method returns a basemap by default. If "wantplan" is TRUE, read method returns a list with:
plan |
a plan, as identified by the BARDplan variable in the shapefile |
basemap |
the basemap |
Write method returns logical success, invisibly.
Using createAssignedPlan with an imported plan is generally more memory efficient than using wantplan=TRUE.
Micah Altman Micah_Altman@harvard.edu http://www.hmdc.harvard.edu/micah_altman/
Other methods for readBardCheckpoint, writeBardCheckpoint,
readBardImage, writeBardImage
# read in a shapefile with demographic data
suffolk.map <- importBardShape(file.path(system.file("shapefiles", package="BARD"),"suffolk_tracts"))
# choose number of districts
ndists <- 5
# create some initial plans
kplan1 <- createKmeansPlan(suffolk.map,ndists)
# read and write images
exportBardShape(file.path(tempdir(),"shape1"),plan=kplan1)
# reimport
suffolk.map2<-importBardShape(file.path(tempdir(),"shape1"))
kplan2<-createAssignedPlan(suffolk.map2)