[R-sig-Geo] How do I ensure that the polygon in spatstat::owin(poly=<polygon>) does not have “negative area”
Roger.Bivand at nhh.no
Fri Sep 20 13:35:02 CEST 2013
On Fri, 20 Sep 2013, Francesco Carotenuto wrote:
> Hi Jeff
> Try to type these lines:
> mass.map <- map("state", "massachusetts:main", fill=T)
> mass.win <- owin(xrange=mass.map$range[1:2],yrange=mass.map$range[3:4] )
This will use the bounding box as a window - there was a response on
R-help giving one resolution:
mass.win <- as(map2SpatialPolygons(mass.map, ID=mass.map$names), "owin")
converting the S3 map class object to an S4 SpatialPolygons object, then
coercing to owin.
Do note that your state boundary is in geographical coordinates rather
than planar, projected coordinates, so you may need to tread carefully if
your subsequent analysis assumes the latter.
> Indeed, using this command:
> you can see that your object mass.map has different columns. Columns x and y are the coordinates of all points describing the contour lines of mass.map object.
> You need to use instead the column "range" that contains the bounding box coordinates.
> In details :
> mass.map$range[1:2] # from 1 to 2 for the x range
> mass.map$range[3:4] # from 3 to 4 for the x range
> Dr. Francesco Carotenuto (Ph.D.)
> Department of Earth Sciences
> Federico II University
> Largo S. Marcellino 10,
> 80138 NAPLES (ITALY)
> [[alternative HTML version deleted]]
Department of Economics, NHH Norwegian School of Economics,
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
More information about the R-sig-Geo