[postgis-users] comparison of nearest neighbour solutions (st_dwithin() vs pgis_fn_nn() ) ?

Obe, Regina robe.dnd at cityofboston.gov
Thu Oct 16 04:44:10 PDT 2008


Smith,
 
Actually I wrote that function and have to update it since its flawed
when dealing with non-point things and was also written pre-existence of
st_dwithin.
 
The difference is that pgis_fn_nn() is designed for returning multiple
near neighbors per record so comes in handy when you have a bulk of
records
 
e.g. 
for each street find the 5 closes houses
 
so if you had a set of 10 records of streets you could get up to 50
records returned back.
 
If you only need the closest record per record - using st_dwithin in
conjunction with distinct on is actually much faster -  take a look at
this example - the one involving DISTINCT ON
 
http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgis_neare
st_neighbor
 
Hope that helps,
Regina

________________________________

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Smith Roman
Sent: Thursday, October 16, 2008 5:19 AM
To: Users Postgis
Subject: [postgis-users] comparison of nearest neighbour solutions
(st_dwithin() vs pgis_fn_nn() ) ?


Hi,
 
Thanks for the links to the postgis wiki on nearest neighbour. I have
postgis 1.3.3 so the use of the st_dwithin() function will work fine for
me because its very simple to use. But i have one more question.
 
 Whats the difference between the use of the st_dwithin() function and
the pgis_fn_nn() function ? I obtained pgis_fn_nn()  from the boston GIS
site
-http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgis_near
est_neighbor_generic 
 
Is one more accurate than the other ?
 
Thanks,
 
Smith.



-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20081016/59ae2328/attachment.html>


More information about the postgis-users mailing list