[postgis-users] Topology: cannot delete slivers (or gaps)

Guillaume Drolet droletguillaume at gmail.com
Tue Nov 4 15:08:15 PST 2014


Hi Sandro and others,

First, thanks Jon for the hint on pprepair: I ran pprepair on my shapefile
and I'm now in the process of 
importing it into PostGIs for topology creation. Then I'll be able to tell
if pprepair really fixed everything.

But because I'm stubborn and never give up, I still want to succeed on
fixing TopoGeometry objects in PostGIS (bear with me, what follows is a bit
long):

Sandro, you said:

> The fix here would be to find faces that take part in the composition
> of multiple TopoGeometry objects and those NOT taking part in the
> composition of any TopoGeometry object. I've seen GRASS GUIs referring
> to those 2 classes as "polygon0" and "polygon2", enough that I've been
> thinking it could be useful to have them shown as layers in the QGIS
> viewer for PostGIS Topology. You should be able to extract those faces
> with a query to the relation and the layers tables.

> So basically you first have to fix the TopoGeometry objects and then
> can safely drop the no-more-needed edges. 

First, I looked at faces NOT taking part in the composition of any
TopoGeometry object:

/SELECT face_id FROM de_20k_topo.face WHERE face_id NOT IN (SELECT
element_id
		                                                                       
FROM de_20k_topo.relation);/
face_id
0
2418
2650
2663
2766
3077
3118
3146
3267
3270

None of these 10 faces are involved with my three remaining slivers... And
when I look at them, they ARE related to edges, as a next_face or a
right_face. Is there any useful information in that for my purpose?

Second, I tried to work along the lines suggested by Sandro, using a new
topology (tolerance 2.0 m). As in one of my previous attempts, I
successfully fixed 20 of the 23 slivers using ST_RemEdgeModFace. For the
remaining three slivers, however, I tried modyfying TopoGeometry objects but
with no success. I must admit I'm a bit lost and not too sure if I really
understand what TopoGeometry objects are:

For example, let's look at problematic face_id: 2227
(https://dl.dropboxusercontent.com/u/5196336/example_2227.bmp). In this
case, the light grey line is where a single edge should be. Blue edges 6381
and 6341 should not be there. The light grey line should start from the node
at the bottom right and connect at its other end somewhere in the middle of
edge 6340:

I thought, let's first remove edge 6346, which should not exist in the first
place, and then split edge 6340 with a node and connect it to node 4753 on
the lower right corner of the image:

SELECT ST_RemEdgeModFace('de_20k_topo', 6346); 

As in my previous post, this yields:

ERROR:  TopoGeom 1546 in layer 1 (syshiera.de_20k.topogeom) cannot be
represented healing faces 2225 and 2227
CONTEXT:  instruction SQL « SELECT topology._ST_RemEdgeCheck(toponame,
topoid, e1id, e1rec.left_face, e1rec.right_face) »
function PL/pgsql st_remedgemodface(character varying,integer), line 43 at
PERFORM

So I looked at TopoGeom 1546:

/SELECT * FROM de_20k_topo.relation WHERE topogeo_id = 1546;/

topogeo_id;layer_id;element_id;element_type
1546;1;2225;3
1546;1;2233;3

Edge 2227 is missing from TopoGeom 1546: Where is it?

/SELECT * FROM de_20k_topo.relation WHERE element_id = 2227;/

topogeo_id;layer_id;element_id;element_type
1551;1;2227;3

There it is, in TopoGeom 1551. What else is there:

/SELECT * FROM de_20k_topo.relation WHERE topogeo_id = 1551;/

topogeo_id;layer_id;element_id;element_type
1551;1;2225;3
1551;1;2234;3
1551;1;2227;3

So edges 2225 and 2227 are associated with TopoGeom 1551. Will change that:

/
UPDATE de_20k_topo.relation SET topogeo_id = 1546
	WHERE topogeo_id = 1551 AND element_id = 2227;/

Query returned successfully: one row affected, 481 ms execution time.

And then again:

/SELECT ST_RemEdgeModFace('de_20k_topo', 6346); /

ERROR:  TopoGeom 1551 in layer 1 (syshiera.de_20k.topogeom) cannot be
represented healing faces 2225 and 2227
CONTEXT:  instruction SQL « SELECT topology._ST_RemEdgeCheck(toponame,
topoid, e1id, e1rec.left_face, e1rec.right_face) »
function PL/pgsql st_remedgemodface(character varying,integer), line 43 at
PERFORM

Obviously, as mentionned above, I don't quite understand how TopoGeometry
objects work and the link between TopoGeoms, geometries and primitives. I
need a bit of education here.

Thanks a lot for your patience and your help.

PS. Remi, thanks for suggesting GRASS but I've never used it and the
learning curve seems pretty steep, no?




--
View this message in context: http://postgis.17.x6.nabble.com/Topology-cannot-delete-slivers-or-gaps-tp5007250p5007273.html
Sent from the PostGIS - User mailing list archive at Nabble.com.


More information about the postgis-users mailing list