[postgis-users] Snapping linestrings with given tolerance

Guillaume Drolet droletguillaume at gmail.com
Wed Nov 21 13:50:35 PST 2012


Hi Nicolas,

I didn't quite follow the tips in the "Closing Coutour" thread but got some
inspiration from it (I think it's a bit complicated for my PostGIS level).

I can now snap lines but some of them (see attached file) don't snap at the
right place. In the attached image, I want the last point of the line in
the southern area (the un-numbered point closest to the north area in grey)
to snap to point 26. Unfortunately, it is point 27 that snapped to 26. The
second image shows another case where the snap didn't do as I expected
(multi snaps on the same line..). In some other cases however, it did work
alright.

I'm sure this has to do with the conditions in my query below but I don't
understand what. Maybe you have some clues about it?

DROP TABLE IF EXISTS hydrology.snappedlines;
SELECT b.gid, ST_Snap(a.geom_intersections, b.geom_intersections, 50) geom
INTO TABLE hydrology.snappedlines
FROM hydrology.nhn_coursdeau_merge_test a, -- lines in the north area
    hydrology.bdtq_20k_hydro_lo_merge_test b, -- lines in the south area
    hydrology.test_north c, -- north area polygon
    hydrology.test_south d      -- south area polygon
WHERE ST_DWithin(a.geom_intersections, b.geom_intersections, 50) -- units
in meters
AND ST_DWithin(a.geom_intersections, c.geom, 0.001)
AND ST_DWithin(a.geom_intersections, d.geom, 0.001)
AND ST_DWithin(b.geom_intersections, c.geom, 0.001)
AND ST_DWithin(b.geom_intersections, d.geom, 0.001);

Thanks for helping,

Guillaume
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121121/5cb14617/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SnappedLines.bmp
Type: image/bmp
Size: 3322158 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121121/5cb14617/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SnappedLines2.bmp
Type: image/bmp
Size: 3322158 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121121/5cb14617/attachment-0003.bin>


More information about the postgis-users mailing list