2

I have a situation where I get routes from drivers and store them in a PostGIS database. What I want is to get a GeoJSON from the whole network covered, without overlaps of road segments. In other words, I would like a "cleared" network (see image) of the driven roads.

enter image description here

At first, I thought of creating a trigger for checking if there are any overlaps before inserting a new route. However, a new route could have overlaps itself, so this approach is declined.

Another thought was to split the routes into the minimum, smallest line segments and then delete the ones that are equal to others. However, I think that storing all these segments as different records could be an overkill for the database (correct me If I am wrong).

Ideally, I am searching for a query that would return all network without duplicates (overlaps). Any ideas?

treecon
  • 183
  • 6
  • You might want to look to ST_Snap and ST_SnapToGrid. Or see this similar question: https://gis.stackexchange.com/questions/260495/snap-lines-to-nearest-line-in-postgis – pLumo Jul 03 '18 at 15:33
  • How about dissolve function? You might have to re-impute some features and break lines at changes in routing function. Or dissolve all features and then a merge with your datasets and edt the attribute table. – lewis Jul 03 '18 at 23:06
  • If you mean you want distinct geometries, as distinct from building a topological network, you can do SELECT geom FROM ... GROUP BY ST_AsBinary(geom) or something similar with DISTINCT. As already stated, you might need to use ST_SnapToGrid if these come from GPS tracks. See this answer and the comments. – John Powell Jul 04 '18 at 09:15

0 Answers0