[postgis-users] -- Caculating distance from an address --

Michael Fuhr mike at fuhr.org
Fri Sep 15 08:13:42 PDT 2006


On Fri, Sep 15, 2006 at 07:48:12AM -0700, Rafael Orta wrote:
> update smarter.vow_properties set geom = makePoint (latitude, longitude);

This should be makePoint(longitude, latitude).  Geometries are (X Y).

> Looking for properties in my table that are around 100 metters from a point.
> ==================================================
> select * from smarter.vow_properties where geom && Expand(GeomFromText('POINT( 39.940252 -074.905868)',-1),100)
> and Distance (GeomFromText('POINT(39.946788 -074.905868)',-1),geom) < 100;
>  
> What I am doing wrong? No matter what distance I place even 1 metter
> it return all the rows.

Expand() and Distance() use the same units as the input geometries,
which in this case is degrees, not meters.  Try expanding by a small
fraction of a degree (0.002 should be reasonable at that latitude)
and use distance_sphere() instead of Distance().  Alternatively,
transform the coordinates to an SRID that uses meter units, such
as the appropriate UTM zone.

-- 
Michael Fuhr



More information about the postgis-users mailing list