I am trying to process a road network file in which certain road links have near-identical duplicates/neighbours.
By "near identical" i mean 2 Linestrings may share the same centroid but have start/end nodes which differ by a few millimeters. In other cases, a certain Linestring may have a near-parallel neighbour which does not share a common centroid; again, this "duplicated" line is typically within a few millimeters of its near-parallel neighbour.
My goal is to remove these near-identical Linestrings to facilitate accurate length calculations.
I have browsed other threads exploring problems similar to this but have yet to find the PostGIS solution that works on this particular task.
- St_SnapToGrid maintains the relationships of the near-identical pairings.
- ST_DWithin test can result in deleting consecutive links rather than coinciding ones.
- ST_Union maintains the original geometry
- ST_Linemerge fails to merge lines if they are too far apart.
This image shows the centroids of each link as well as the selection of two near-identical links, one of which also overlaps another link at its higher end.
PostGreSQL version: 9.6.5 PostGIS version 2.4.0 GEOS 3.6.2 GDAL 2.2.2 LibJson 0.12