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.
--
View this message in context: http://postgis.17.x6.nabble.com/Topology-cannot-delete-slivers-or-gaps-tp5007250p5007278.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
On Fri, 2014-11-07 at 13:14 -0800, Guillaume Drolet wrote:
> I finally finished cleaning my topology, using a mix of SQL commands,
> functions, and also using Sandro's QGIS topology editor plugin.
>
> In parallel, I also tried going the GRASS route, importing my original
> shapefile in GRASS and applying the cleaning function (v.clean ...) as
> suggested by Remi. I injected the result into PostGIS and created a
> topology. Most of the 23 slivers were there in the topology so one of two
> things: 1) GRASS didn't fix them (maybe I didn't choose an appropriate
> tolerance) or 2) they were created by PostGIS when building the topology.
Simplifying polygons with QGIS and GRASS
Note: SRID = 4326
1) Open shapefile in QGIS
2) Create New Mapset
Import Extent from opened Shapefile
3) Check the smaller area of the polygons involved
select ST_Area (geo_polygon) from table order by
ST_Area(geo_polygon);
Smaller area = 0.005471
4) Import shapefile into GRASS
v.in.ogr dsn = /home/humberto/shapefiles/pr/41MUE250GC_SIR.shp
output = prGrass snap = 0.0001 min_area = 0.004 -o
Settings of parameters: Snapping threshold for boundaries = 0.0001
and Minimum size of area to be imported (squere units) = 0.004
Note: The 0.004 value was chosen to allow importing of the smaller
area = 0.005 and all areas greater than it, avoiding any small ring that
would be arising from this importing.
5) Simplify the Shapefile polygon imported
v.generalize input=prGrass@elimSlivers type=area layer=1 -c
type=boundary method=douglas threshold=0.001 look_ahead=7 reduction=50
slide=0.5 angle_thresh=3 degree_thresh=0 closeness_thresh=0
betweeness_thresh=0 alpha=1.0 beta=1.0 iterations=1
output=prGrassGeneralized
Settings of parameters: threshold = 0.001
Note: the threshold value 0.001 was chosen by trial
6) Export the simplified polygon to Postgis
v.out.ogr.pg.py input=prGrassGeneralized@elimSlivers type=area
layer=1 olayer=prgeneralized database=simp22 host=127.0.0.1 port=5432
user=name password=nonono
>
> Anyway, I got what I finally got what I need, thanks a lot to all of you who
> helped me.
>
> I'm gonna ask you one last thing if I may: I want to replace the original
> geom column (i.e. that used to build the topogeom) with a topologically
> correct one, and keep all the associated ecological attributes. Is this the
> right way to do it:
>
> UPDATE syshiera.de_20k SET geom = topogeom::geometry; ?
>
> Thanks.
>
>
>
> --
> View this message in context: http://postgis.17.x6.nabble.com/Topology-cannot-delete-slivers-or-gaps-tp5007250p5007286.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
> _______________________________________________
> postgis-users mailing list
> postgi...@lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Thanks,
Humberto
On Wed, 2014-11-12 at 10:51 +0100, Rémi Cura wrote:
> Note you could have directly exported into postgis topology, which is
> slow but very convenient (stil faster than postgis topology
> conversion).
>
> I'm not a grass user,
>
> from what I understood you have to use the "-l" switch in the command
> "v.out.postgis"
Thanks for your tip. It will be useful for make good use of Postgis
topology.
>
>
> Glad it helped =)
>
> Cheers,
> Rémi-C
Cheers,
Humberto