[postgis-users] Rép: Nearest Neighbor question
Hugues François
hugues.francois at irstea.fr
Fri May 23 00:01:16 PDT 2014
Hi,
You can simply try to use order by distance and limit statements.
SELECT * FROM pt_table
ORDER BY ST_Distance(ST_MakePoint(lon,lat, 4326), geom)
LIMIT 4
Of course you clan use ST_Transform to ensure the consistence of your data.
HTH
Hug
Gerry Creager - NOAA Affiliate <gerry.creager at noaa.gov> a écrit :
I need to query a rather smallish database and return 4 points closest to a
lat/lon (or lon/lat, if you prefer) statement. I've been off-line from
PostGIS and my skills are worse than rusty right now...
Thanks
Gerry
--
Gerry Creager
NSSL/CIMMS
405.325.6371
++++++++++++++++++++++
“Big whorls have little whorls,
That feed on their velocity;
And little whorls have lesser whorls,
And so on to viscosity.”
Lewis Fry Richardson (1881-1953)
More information about the postgis-users
mailing list