Bastien Ferland-Raymond
2010-Jun-29 17:36 UTC
[R] how to create a shape file from a polygone
Dear R-users, I have created a map with plot location using longitude/latitude coordinates with the PlotOnStaticMap() function of the RgoogleMaps package. Everything works fine until I try to put a polygon on the map. The polygon() function doesn?t work and I need to use the special function PlotPolysOnStaticMap() however this requires a shapefile (which I'm not sure what it is) and not XY coordinates. So my question is quite simple: How do I transform XY (lon/lat) coordinates into a shape file. My polygon: x.pol.mat<-c(-66.67,-66.46,-66.54,-66.82,-67.06,-66.97) y.pol.mat<-c(48.87,48.89,48.745,48.62,48.55,48.75) pol.mat<-matrix(c(x.pol.mat,y.pol.mat),6,2) polygon(pol.mat) The writePolyShape() function from the maptools package seems to be what I'm looking for but I can't figure how to create the SpatialPolygonsDataFrame object that is required. I'm using WinXP pro 32bit and R 2.11.0 Thanks for your help, Bastien Ferland-Raymond, M.Sc. candidate Universit? Laval Qu?bec, Canada __________ Information from ESET NOD32 Antivirus, version of virus signature database 5235 (20100628) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com