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

Humberto Cereser Ibanez humberto at pastoraldacrianca.org.br
Mon Nov 10 04:56:40 PST 2014


I was with the same problem, getting gaps in some adjacent polygons
while trying to simplify polygons with Postgis.
Thank Guillaume / Rémi / Sandro by the contributions.
Illuminated by this thread, I created a script in which I avoided gaps
from the bad polygons. Really the most appropriate tool, GRASS, became
this work easier.

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 at 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 at 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
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

Thanks,

Humberto



More information about the postgis-users mailing list