Smathermather's Weblog

Remote Sensing, GIS, Ecology, and Oddball Techniques

Cost of nearest neighbor search depending on distance

Posted by smathermather on April 24, 2010

A quick review of costs to search with increasing distances.  Reference this original post for the code being run.

SELECT DISTINCT ON(g1.gid)  g1.gid as gid, g2.gid as gid_ground, g1.x as x, g1.y as y, g2.z as z, g1.z - g2.z as height, g1.the_geom as geometry
 FROM veg As g1, ground As g2   
 WHERE g1.gid <> g2.gid AND ST_DWithin(g1.the_geom, g2.the_geom, 3.5)   
 ORDER BY g1.gid, ST_Distance(g1.the_geom,g2.the_geom);

This is the total query time comparing 167,000 to 222,000 points using ST_DWithin to do a nearest neighbor search with different search distances.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: