[R-sig-Geo] Area left in shape file

Rolf Turner r.turner at auckland.ac.nz
Tue Sep 11 01:25:13 CEST 2012


On 11/09/12 10:31, Juan Tomas Sayago wrote:
> Dear list,
> I have two shapes with polygons, and need to find the area in one of them
> that is not covered by the other. What do you recommend?
> Thanks
> Juan

You can use the functions area.owin() and setminus.owin() from
the "spatstat" package.  E.g.

     area.owin(setminus(A,B))

will give the area of that part of A not covered by B.

Note that A and B have to be objects of class owin; use the function
as.owin() to convert polygons to such objects.  See vignette("shapefiles")
for some guidance.

Note that setminus(A,B) will yield an owin object of type *mask*
(whence your answer will be an approximation via "pixellation")
unless "gcplib" is available and enabled (by setting:

     spatstat.options(gpclib=TRUE)

If you set gpclib=TRUE make sure that your use of this package
does not conflict with its unfortunately restrictive licensing terms.
(See license.polygons().)

     cheers,

         Rolf Turner



More information about the R-sig-Geo mailing list