[R-sig-Geo] R-sig-Geo Digest, Vol 69, Issue 3

Patrick Giraudoux patrick.giraudoux at univ-fcomte.fr
Sun May 3 19:46:00 CEST 2009

> ----------------------------------------------------------------------
> Message: 1
> Date: Sat, 02 May 2009 22:52:36 -0500
> From: Jim Burke <j.burke at earthlink.net>
> Subject: [R-sig-Geo] How can I convert a "SpatialPolygons" object to a
> 	"polylist"?
> To: r-sig-geo at stat.math.ethz.ch
> Message-ID: <49FD1504.7060101 at earthlink.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> How can I convert a "SpatialPolygons" object to a "polylist" 
> I have a file read in with "readShapePoly". This contains the polygon
> long lats in a slot called "coords". I want to use the package "splancs"
> "inout" function which works according to the doc with polygon data sets.
> An example Map2Poly which works with "inout" lists itself as a class 
> "polylist".  
> Thanks,
> Jim Burke

if your SpatialPolygons name is e.g. myObject

lapply(myObject at polygons, function(x) x at Polygons[[1]]@coords)

should make it in the very simple case (the most common too anyway) 
where each attribute line corresponds to one single polygon. It will 
provide you with a list whose elements will be the coordinates of each 

More complex cases are a bit more difficult to handle


More information about the R-sig-Geo mailing list