New answers tagged

0

For a naive approach you can use this SQL select: SELECT v.nev, f.nev, ST_Distance(v.geom, f.geom) FROM varos AS v CROSS JOIN folyo AS f WHERE (v.nev, ST_Distance(v.geom, f.geom)) in ( SELECT varos.nev, min(ST_Distance(varos.geom, folyo.geom)) FROM varos CROSS JOIN folyo WHERE varos.nev = v.nev GROUP BY varos.nev); This Query selects the nearest city ...


1

First, using <#> will only compare bounding boxes. If you have PostGIS 2.2 (or greater in the future) you can use <-> operator to get the real distance calculation. That means that after the index search a recheck is done to find out the real distance. Second, as John B commented, the knn-functions need a constant to work with. Since you are building ...



Top 50 recent answers are included