I\'m trying to create a shapefile in R that I will later import to either Fusion Table or some other GIS application.
To start,I imported a blank shapefile containing al
Use rgdal
and writeOGR
. rgdal
will preserve the projection information
something like
library(rdgal)
shape <- readOGR(dsn = 'C:/TEST', layer = 'blank_ct')
# do your processing
shape@data = data.frame(shape@data, data2[match(shape@data$CTUID, data2$CTUID),]) #data2 is my created attributes that I'm attaching to blank file
shape1 <-shape[shape$CMAUID == 933,]
writeOGR(shape1, dsn = 'C:/TEST', layer ='newstuff', driver = 'ESRI Shapefile')
Note that the dsn
is the folder containing the .shp
file, and the layer
is the name of the shapefile without the .shp
extension. It will read (readOGR
) and write (writeOGR
) all the component files (.dbf
, .shp
, .prj
etc)