Hi martin,<br>I had got no particular example.<br>But, if I have to find intersections and get a geometry collection, I&#39;ll keep your approach in mind and only look at the right (0, 1 or 2D) components of a geometry collection. In my case, I was only interested in 2D parts (wrong intersections between buildings/polygons I have to fix).<br>
Thanks<br><br><div class="gmail_quote">2009/3/16 Martin Davis <span dir="ltr">&lt;<a href="mailto:mbdavis@refractions.net">mbdavis@refractions.net</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Yep, that&#39;s what you&#39;d have to do. <br>
Probably a better way to think of this is that you need to decide what dimension of geometry you are interested in out of the intersection operation.  Then you retain only those components of the result.  In this case, since you are checking whether the intersection is equal to one of the input polygons, you should retain only the 2D components of the intersection result.<br>

<br>
I realize that it would be nice to have it a bit simpler to get the desired dimension components from an intersection result.  One idea is to ensure that a result GEOMETRYCOLLECTION contains at most 3 (possible multi) geometry components, one each for the 0-D, 1-D, and 2-D components. <br>

In general if you are testing spatial relationships you should try and use just predicates.  This will be faster and more accurate.  What are the other cases which you think will not be as simple?<br>
<br>
Pascal Leroux wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
Does it mean that, when I get a geometry collection, the very first thing I have to do is to split it into simple/multiple but homogeneous geometries to go on ?<br>
<br>
In the script I&#39;ve posted, I could have use &quot;contains&quot; or &quot;within&quot; with the two polygons instead of &quot;equals&quot; with the intersection, but in others cases, I&#39;m afraid it is not so easy/simple !<br>

<br>
Can you give me an advice ?<br>
<br>
Pascal<br>
<br></div>
2009/3/16 Sean Gillies &lt;<a href="mailto:sgillies@frii.com" target="_blank">sgillies@frii.com</a> &lt;mailto:<a href="mailto:sgillies@frii.com" target="_blank">sgillies@frii.com</a>&gt;&gt;<div><div></div><div class="h5">
<br>
<br>
    The GEOS C API returns a integer value of 2 to indicate an error.<br>
    It&#39;s good to learn that geometry collection predicates aren&#39;t<br>
    supported.<br>
<br>
<br>
    On Mar 16, 2009, at 9:46 AM, Martin Davis wrote:<br>
<br>
        GEOS does not support evaluating predicates on<br>
        GEOMETRYCOLLECTIONS (due to the potential complexity and lack<br>
        of obvious semantics of heterogeneous collections).<br>
<br>
        In JTS trying to do this throws an exception.  I&#39;m not sure<br>
        how GEOS reacts - or possibly shapely is not handling this<br>
        gracefully?<br>
<br>
        Pascal Leroux wrote:<br>
<br>
            Hi all<br>
<br>
            while searching for intersections between polygons<br>
            (buildings), I have found shapes that make &quot;equals&quot;<br>
            predicate crash. With simpler shapes, it occurs too :<br>
<br>
            &gt;&gt;&gt; from shapely.geometry import Polygon<br>
            &gt;&gt;&gt; p1 =<br>
            Polygon(((0,0),(0,10),(10,10),(10,0),(8,0),(8,8),(2,8),(2,0)))<br>
            &gt;&gt;&gt; p2 = Polygon(((2,0),(2,8),(8,8),(7,4),(8,0)))<br>
            &gt;&gt;&gt; inter = p1.intersection(p2)<br>
            &gt;&gt;&gt; inter.is_valid and p1.is_valid and p2.is_valid<br>
            True<br>
            &gt;&gt;&gt; inter.wkt<br>
            &#39;GEOMETRYCOLLECTION (POINT (8.0000000000000000<br>
            0.0000000000000000), LINESTRING (8.0000000000000000<br>
            8.0000000000000000, 2.0000000000000000<br>
            8.0000000000000000), LINESTRING (2.0000000000000000<br>
            8.0000000000000000, 2.0000000000000000 0.0000000000000000))&#39;<br>
            &gt;&gt;&gt; inter.equals(p1)<br>
            False<br>
            &gt;&gt;&gt; inter.equals(p2)<br>
            Traceback (most recent call last):<br>
             File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br>
             File<br>
            &quot;/usr/lib/python2.5/site-packages/Shapely-1.0.11-py2.5.egg/shapely/predicates.py&quot;,<br>
            line 34, in __call__<br>
              return bool(self.fn(self.context._geom, other._geom))<br>
             File<br>
            &quot;/usr/lib/python2.5/site-packages/Shapely-1.0.11-py2.5.egg/shapely/predicates.py&quot;,<br>
            line 21, in errcheck<br>
              raise PredicateError, &quot;Failed to evaluate %s&quot; %<br>
            repr(self.fn)<br>
            shapely.geos.PredicateError: Failed to evaluate &lt;_FuncPtr<br>
            object at 0x96a3bf4&gt;<br>
<br>
            I have got a Bus Error on MacOSX (libgeos version 3.0.0)<br>
            and a Segmentation Fault on Ubuntu (libgeos version 3.0.3)<br>
            with an equivalent code written in C (so I think Shapely<br>
            is not involved).<br>
<br>
            Any idea ? Did I miss something ?<br>
<br>
            Pascal<br>
            ------------------------------------------------------------------------<br>
<br>
            _______________________________________________<br>
            geos-devel mailing list<br></div></div>
            <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a> &lt;mailto:<a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a>&gt;<div class="im">
<br>
            <a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
<br>
<br>
        --         Martin Davis<br>
        Senior Technical Architect<br>
        Refractions Research, Inc.<br>
        (250) 383-3022<br>
<br>
        _______________________________________________<br>
        geos-devel mailing list<br></div>
        <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a> &lt;mailto:<a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a>&gt;<div class="im">
<br>
        <a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
<br>
<br>
    _______________________________________________<br>
    geos-devel mailing list<br></div>
    <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a> &lt;mailto:<a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a>&gt;<div class="im"><br>

    <a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
<br>
<br>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
geos-devel mailing list<br>
<a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
</div></blockquote><div><div></div><div class="h5">
<br>
-- <br>
Martin Davis<br>
Senior Technical Architect<br>
Refractions Research, Inc.<br>
(250) 383-3022<br>
<br>
_______________________________________________<br>
geos-devel mailing list<br>
<a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
</div></div></blockquote></div><br>