Help with anti-clockwise polygon in owin
On Thu, 8 Jan 2009, Corey Sparks wrote:
Dear list, I have a point pattern that consists of wells on an island. I am interested doing some exploratory point pattern analysis on this data (such as Gest in spatstat). The island as you can imagine is an irregular polygon defined by 1815 points. When I try to create the observation window for the point pattern in spatstat using owin(x=range(westcoords$X), y=range(westcoords$Y), poly=list(x=westcoords$X, y=westcoords$Y)) where westcoords are the coordinated of the polygon I get: Error in owin(x = range(westcoords$X), y = range(westcoords$Y), poly = list(x = westcoords$X, : Area of polygon is negative - maybe traversed in wrong direction? Since the origin of the coordinates is a shapefile I created myself, how can I get around this "traversed in the wrong direction" problem? I can make the data this is based on available if anyone would need it.
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
I'm using R 2.8.1 on a Mac with Leopard OS Thanks, Corey Corey Sparks Assistant Professor Department of Demography and Organization Studies University of Texas at San Antonio One UTSA Circle San Antonio, TX 78249 210 458 6858 corey.sparks at utsa.edu
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no