[QGIS-trac] Re: [Quantum GIS] #2921: Avoid intersection of new
polygons.. IS BROKEN
Quantum GIS
qgis at qgis.org
Sat Apr 16 18:52:45 EDT 2011
#2921: Avoid intersection of new polygons.. IS BROKEN
-----------------------------------------------------+----------------------
Reporter: pinux | Owner: mhugent
Type: bug | Status: reopened
Priority: major: does not work as expected | Milestone: Version 1.7.0
Component: Digitising | Version: Trunk
Resolution: | Keywords: intersection, polygons
Platform_version: | Platform: All
Must_fix: Yes | Status_info: 0
-----------------------------------------------------+----------------------
Changes (by mayeulk):
* priority: critical: causes crash or data corruption => major: does not
work as expected
* platform: Windows => All
* version: 1.5.0 => Trunk
Comment:
Hi,
I can confirm most of the above, with some comments which might help
debugging.
You can try this query:
{{{
select *, st_area(geom), st_isvalid(geom) from (select a.gid + b.gid *
100 AS gid, a.gid AS a_gid, b.gid AS b_gid,
st_setsrid((st_intersection(a.the_geom, b.the_geom)), 4326) as geom
FROM av_intersection a, av_intersection b
WHERE a.gid < b.gid AND st_overlaps(b.the_geom, a.the_geom)) as
the_intersects;
}}}
You'll see that 2 thirds of the intersections have a null area. For the
other ones, their area is always (on my machine) 0.00048828125 and I
believe it is a Postgis/geos error, see below:
{{{
WITH av_intersect_911 as (
select 91104 AS gid,
st_setsrid(ST_GeometryN((st_intersection(a.the_geom, b.the_geom)),4),
4326) as geom
FROM av_intersection a, av_intersection b
WHERE a.gid=9 and b.gid=11
limit 1)
SELECT gid, geom, GeometryType (av_intersect_911.geom),
st_area(av_intersect_911.geom), ST_AsEWKT (av_intersect_911.geom)
FROM av_intersect_911;
}}}
The above query shows a polygon which is (part of) the intersection of
polygons 9 and 11. It's area is 0.00048828125. This polygon has this EWKT
definition:
{{{
"SRID=4326;POLYGON((
1517034.97851789 5634807.73109361,
1517034.97851789 5634807.73109361,
1517034.11662417 5634808.29056848,
1517034.97851789 5634807.73109361))"
}}}
Since 3 of its four points are identical, it is trivial to say that this
polygon is flat and its area is zero, hence the area computation is false.
I am not 100% sure that there are "real" intersections, as several of the
intersections are not polygons but lines at the boundary of 2 polygons.
Still, I agree that the topology is incorrect: the topology is broken.
Still, this does not corrupt existing data nor create invalid geometry:
they can be displayed in qgis and the following is true in postgis:
{{{
select st_isvalid(the_geom) from av_intersection;
}}}
Given this postgis bug, I tried to reproduce this with a shapefile (to
make sure that we are hunting a QGIS bug, not a postgis bug).
Below an ASCCI art explanation of what I found, please see also attached
screenshot and attached shapefile.
{{{
You have A:
____
|
A |
-----
You add B:
____________
|B /
A | /
----|----/
Everything is OK until you add C:
____
/ C \
_/______\___
|B /
A | /
----|----/
You expect C to be like this:
____
/ C \
/______\
The topological error that I can confirm is the following: C is like this:
____
/ C \
/______\
|
|
My conclusion:
When you add a polygon C where two polygons A and B are
touching (or are supposed to), then C will have a leg going
in between A and B. It is not clear whether A and B are
strictly contiguous or if there is an (unwanted) hole between
them.
}}}
--
Ticket URL: <http://trac.osgeo.org/qgis/ticket/2921#comment:10>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS supporting GDAL/OGR, PostGIS, and GRASS formats, and Web Services
More information about the QGIS-trac
mailing list