[R-sig-Geo] Problem in converting SpatialPolygonsDataFrame to owin object

Adrian Baddeley adrian at maths.uwa.edu.au
Fri Sep 15 05:37:04 CEST 2006


Debarchana Ghosh reports a problem in converting an object
of class SpatialPolygonsDataFrame to class 'owin'.

Without any other information (without the data and knowing 
nothing about 'sp') my guess is that you are trying to 
make a single polygonal region out of several polygons that are adjoining 
i.e. there are two polygons that share an edge, like the 
borders of adjoining countries.

Did you want to end up with a single region of space,
or with a list of different regions?

In the spatstat package, an object of class `owin' always represents 
a region of space with an inside, an outside and a boundary. 
To create a region with a polygonal boundary, you have to supply
the coordinates of the *boundary* line segments. That is, every 
edge of your polygon must be part of the *boundary* of the spatial region
(the region separating the inside from the outside).

For example, to define the USA as an owin object, 
you would supply the coordinates of the international borders
(USA-Canada and USA-Mexico) and the ocean coast, but **not** the 
interstate borders.

When you create a polygonal region as an object of class 'owin',
spatstat checks its validity by checking for
	 - self-intersection in each polygon
	 - intersections between different polygons
	   (including common boundaries).
It will not automatically `join' together two adjacent polygons.
That kind of functionality is better handled by other code like gpclib.

Alternatively you can convert each separate polygon
to an `owin' object, then use 'union.owin' to compute their union
(which is doen by converting the polygons to binary images).

Adrian Baddeley




More information about the R-sig-Geo mailing list