TransWikia.com

Group PostGIS table-rows where geometries are close

Geographic Information Systems Asked on June 30, 2021

In OSM there are often e.g. lines (paths) with the same name but different OSM-IDs. Right next to each other, so basically the same thing, but just different objects with no real relation to each other.

So in my table it would look like the following

osm_id    name      highway    geometry
---------------------------------------------
1         trail_1   path       <some-line>
2         trail_1   path       <some-line>
3         trail_2   path       <some-line>

I looked at ST_ClusterDBSCAN and that looks promising?!? I am just too bad with SQL to fully understand it.

So I’d like to group my lines by name, cluster them, look at each cluster -> take the metadata (osm_id, name, highway,… ) of one of them and also the combined geometry (ST_LineMerge or ST_Union?!?) of all of them -> Save as a new entry in a separate table.

So from my example in a separate table I only want to have TWO entries left:

osm_id    name      highway    geometry
---------------------------------------------
1         trail_1   path       <some-merged-line>
3         trail_2   path       <some-line>

I am not really sure yet how to tackle the whole thing. Can I do that solely in PostGIS?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP