I'd like to make the equivalent function of QGIS's distance to hub algorithms. Is ST_Distance the right approach to start with? Or is that algorithm transposable into something I can let Postgres PostGIS?
Asked
Active
Viewed 200 times
1
1 Answers
1
Yeah should be very simple:
select a.id, b.id, st_distance(a.geom, b.geom)
from
hub_table a,
locations_table b
Which would get the distance to all points from all hubs.
HeikkiVesanto
- 16,433
- 2
- 46
- 68
LATERAL JOINconstruct using the<->KNN operator; the spatial index will be used to it's full potential (whereas the on-the-flyST_Union/ST_Collectgeometry can't). check a working exampe (yes, it's my own answer...) for the general structure. – geozelot Dec 07 '18 at 10:40