[Qgis-developer] intersect error
wonder.sk at gmail.com
Thu Jan 22 08:24:33 EST 2009
On Thu, Jan 22, 2009 at 1:43 AM, Carson Farmer <carson.farmer at gmail.com> wrote:
> Hi gang,
> Can anyone tell me why when I attempt to intersect the geometries of these
> two features, I get an empty geometry?
> The really odd bit is that differencing or combining the geometries works
> fine... just not intersection... exporting to wkt yields nothing for
> intersection (i.e. empty), whereas exporting the difference or combination
> of the geometries prints out nicely.
>  http://www.ftools.ca/extras/problem_features.zip
> Any tips or hints are much appreciated...
from a quick check I see that the resulting geometry is geometry
collection - the intersection is polygon and polyline from shared
border. Support for geometry collections isn't implemented in QGIS
(wkbType returns "Unknown"). Here are my ideas for you:
1. implement support for geometry collections: probably a partial
implementation allowing to retrieve parts of geometry collection from
GEOS would suffice for the begin.
2. implement relate() function using GEOS which would take a geometry
and intersection matrix as parameters. In the intersection matrix you
could specify that you're not interested in boundaries so you should
get just polygons.
3. for problematic cases use this trick (G1 and G2 are geometries for
- Gx = G1.combine(G2)
- Gy = G1.symDifference(G2)
- G = Gx.difference(Gy)
Now G should contain the intersection, without the border. It works
with your test case, I think it should work in other cases too. This
option takes least effort (no C++ coding) but is also least effective,
so it's your choice :)
More information about the Qgis-developer