[postgis-users] st_dwithin

Ilya Sterin sterini at gmail.com
Tue May 11 08:30:47 PDT 2010

Would something like this be inefficient?  I store data in a geometry
type, as I don't really care about the spheroid accuracy, as my
location queries are mostly less than 30 km apart.  So...

SELECT ST_AsGeoJSON(location), title, description
FROM event
WHERE ST_DWithin(location::geography,
ST_GeogFromText('POINT(-83.359752 42.521268999999997)'),4000)
ORDER BY ST_Distance(location,
ST_GeomFromText('SRID=4326;POINT(-83.359752 42.521268999999997)'))

I cast geom to geog and perform st_dwithin and order by proximity.


On Tue, May 11, 2010 at 8:37 AM, Emilie Laffray
<emilie.laffray at gmail.com> wrote:
> On 11 May 2010 07:34, Malm Paul <paul.malm at saabgroup.com> wrote:
>> Hi,
>> I have a database stored in WGS84 EPSG:4326
>> I would like ti find objects within a distance from a lat/lon point.
>> 1) If i use 1 degree as the distance, will I then get an eliptic search
>> area?
>> 2) Will i find objects on the other side of the Datum shift border if I
>> enter a point like lat=60°, lon= -179,5° with a distance of 1°?
>> 3) Hov do I enter a lat/lon point and a distance in meters?
> If you want to do something that works but is relatively inefficient for 3,
> you can do the following:
> ST_DWithin() AND ST_DistanceSphere() < distance in meters
> Of course, you would have to make sure that the search radius is big enough
> to correspond to your search in meters. Of course, it works only for points
> due to ST_DistanceSphere.
> If you want to perform something with any geometry, look at postgis 1.5 and
> the new geography type.
> Emilie Laffray
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

More information about the postgis-users mailing list