[geos-devel] What do GEOSSymDifference and GEOSIntersection (CAPI) do?

Roger Bivand Roger.Bivand at nhh.no
Wed Feb 10 04:46:33 EST 2010

Continuing to try to interface R and GEOS (CAPI), I am puzzled that 
GEOSSymDifference() and GEOSIntersection() seem to require input objects 
to be "Geometry must be a Point or LineString".

When MULTIPOLYGON or POLYGON objects are degraded to LINEARRING, 
GEOSSymDifference() returns MULTILINESTRING and GEOSIntersection() returns 
MULTIPOINT objects. Are these functions not intended to take at least 
POLYGON inputs, and then return POLYGON output? The cryptic notes in


suggest that they don't:

"intersection (const Geometry *other) const Returns a Geometry 
representing the points shared by this Geometry and other."

"symDifference (const Geometry *other) const Returns a set combining the 
points in this Geometry not in other, and the points in other not in this 

If this is all the functions do by design, how should the POLYGON objects 
be reconstructed, since the distinction between exterior and interior 
rings has been lost? Is there example code anywhere? The code in OGR 
doesn't help here, I'm afraid. Is this the OGC SFS understanding of these 
functions - is that the ontological problem that I'm having coming from 
the outside?

I'm running GEOS 3.2.0, built locally on RHEL5 x86_64.

For union, UnionCascaded of a MULTIPOLYGON returns a POLYGON or 
MULTIPOLYGON, as one would expect.

Grateful for advice,


PS. the previous thread that I opened is still unresolved, and GEOS in R 
(if it is submitted at all), will be published with a big question mark 
about precision and scaling with regard to the dissolving of contiguous 

For now establishing whether GEOS can do geometry operations on 
(multi)-polygons is crucial. GEOS ought to be able to deliver, but I need 
to be shown how - example code, proper documentation of the C API (saying 
what can be used as arguments to functions as a start without having to 
delve through arcane C++ documentation which may or may not apply to the C 
API) - I should proceed.

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

More information about the geos-devel mailing list