Skip to content
Prev 4786 / 29559 Next

Help with anti-clockwise polygon in owin

On Thu, 8 Jan 2009, Corey Sparks wrote:

            
Could you try using readShapeSpatial() in maptools to read in the 
shapefile, then coerce the polygon object to an owin object, something 
like:

library(maptools)
pl_obj <- readShapeSpatial("my_file.shp")
class(pl_obj)
plot(pl_obj, axes=TRUE)
owin_obj <- as(as(pl_obj, "SpatialPolygons"), "owin")
plot(owin_obj)

The reason for doing this is that if a ring in a SpatialPolygons... 
object, created by nested calls to Polygon, does not seem to be a hole - 
that is that it is a singleton ring in this case, its ring direction will 
be reversed automatically. The heuristics are only approximate, but may 
get you where you want to go. If this doesn't help, see if you can make 
the offending shapefile available for helpers to hack on.

Roger