[postgis-users] Nearest Operator

Michael O'Sullivan mos at i3sp.com
Fri May 9 20:08:10 PDT 2003


 > Dear all,
 > Is PostGIS planned to include nearest operator? Just like SDO_NN
 > operator in
 > Oracle Spatial.


Try looking at the FAQ (http://postgis.refractions.net/docs/c191.html)

8. What is the best way to find all objects within a radius of another 
object?


I use something like this to find the nearest point in the database to a 
given point. I do a bounding box query as in the FAQ and then select the 
minimum distance (calculated using length_spheroid) of the subset of 
points to get the closest point to a given point. Depending on what your 
data set is (e.g. a projected coordinate system or lat long) you may 
want to use the distance function rather than length_spheriod.
My geometries are all Lat/Long based POINT objects (in this case).


hope this helps,

Michael


-- 
Michael O'Sullivan <mos at i3sp.com>
"A good man always knows his limitations" - HC




More information about the postgis-users mailing list