[postgis-users] select points within distance

Arne Pallentin a.pallentin at niwa.co.nz
Mon Aug 10 06:20:51 PDT 2009

Hi all,

I'm new to PostGIS, and I run into a problem that I can't solve with documentation and my brain. Maybe someone here can give me a hint in the right direction.

I run postgresql 8.3. with PsotGIS 1.3.6 on WIN32. I have several tables for points, geometries are there, set to Long= 0-360 for all. They all display fine in QGIS. I want to combine these in one table, but eliminate all points deemed dublicates (on basis of their distance to each other).

At the moment I try to select points like this (I have all points in an intermediate table):

SELECT ws.* 
FROM ws, nz, al 
WHERE ws.al_id = al."ID" 
AND nz.the_geom && al.the_geom::box2d 
AND ST_Distance(nz.the_geom, al.the_geom) < 0.06

This works fine for one table, but any other table this fails. All tables were loaded from shape files via QGIS. Indexes (GiST) are all build.

Not sure this is enough information, happy to provide more, but I don't know what...as I said, this is new to me.


NIWA is the trading name of the National Institute of Water & Atmospheric Research Ltd.

More information about the postgis-users mailing list