[R] Re ading and Creating Shape Files

Nikhil Kaza nikhil.list at gmail.com
Fri Oct 30 05:55:39 CET 2009


Have you tried
readShapePoints
writePointsShape

both in maptools.

Also, I don't think you really need a proj4string  specified unless  
you are actually doing some spatial operations such as buffers and  
distances.

I take it that you have already considered and discarded the  
possibility of using using a unique ID for the tax records  and after  
the analysis in R just joining the resulting table in a GIS to your  
original shapefile.

Nikhil


On 28 Oct 2009, at 1:33PM, PDXRugger wrote:

>
> Hello R Community,
>   I have imported a dataset which contain X Y coordinates and would  
> like to
> recreate a shape file after some data analysis.  What i have done is  
> to
> import some taxlot data and join them based on some criteria.  I  
> want to
> check to see how well the joining went by reviewing the results in  
> GIS.
>
> A couple things.  I cant seem to import a shape file correctly using  
> the
> maptools package and the readShapeSpatial.  I have tried
>
> Building=file("data/input/BuildingShape/Building.shp")
> Bldg<-readShapeSpatial(fn=data/input/BuildingShape/ 
> Building,proj4string=NAD83)
> #----------------------
> Bldg<-readShapeSpatial(data/input/BuildingShape/ 
> Building,proj4string=NAD83)
> #---------------
> Building=file("data/input/BuildingShape/Building.shp")
> Bldg<-readShapeSpatial(Building,proj4string=NAD83)
>
> I know i am mis interpreting the documentation but it doesnt seem  
> like it is
> very complicated so i am of course confused.
>
>
> Also, i am wondering if i can create a shape file by simply using XY
> coordinates from a data frame.
> So for:
>
>
> Ycoord=c( 865296.4, 865151.5, 865457.0 ,865363.4 ,865311.0, 865260.9
> ,865210.7 ,865173.3,
> 865123.6 ,865038.2 ,864841.1 ,864745.4 ,864429.1 ,864795.6 ,864334.9
> ,864882.0)
>
> Xcoord=c( 4227640 ,4227816 ,4228929 ,4228508 ,4229569 ,4229498 , 
> 4226747,
> 4226781, 4229597,
> 4229204, 4228910, 4228959 ,4229465 ,4229794 ,4229596 ,4229082)
>
> Lot<-c(1900 , 2000,  2100  , 100   ,200  , 300,   400 ,  500 ,   
> 600 ,  701 ,
> 900 , 1000 , 1100,
>  300   ,100,   200)
>
> XYcoord<-spCbind(Ycoord,Xcoord) #doesnt work so
>
> XYcoord=c(Ycoord,Xcoord)
>
> TaxLots<-cbind(Ycoord,Xcoord,Lot)
>
> writeSpatialShape(XYcoord, TaxLots..,
> file=data/input/test/Taxlots,strictFilename=FALSE)
>
>
>
> So help reading in shape files and then creating them using XY  
> coordinates
> if possible
> Any help would be appreciated.  Thank you.
>
>
>
>
> -- 
> View this message in context: http://www.nabble.com/Reading-and-Creating-Shape-Files-tp26098828p26098828.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list