Fast nearest neighbour in PostGIS

A common task when using GIS is to solve nearest neighbour queries, for example to find closest lake or closest school to a table of households. If the table to search for the closest neighbour is large with thousands or even millions of records, it will be a very heavy and costly to do the search by computing and comparing the distance to every feature. A common solution is to narrow the search by first applying an indexed based search with ST_Dwithin. Different methods to do this is discussed at

Leave a Reply

Your email address will not be published. Required fields are marked *