Search code examples
gispostgiswgs84

postgis get geometries within a radius of meters using wgs84


select *
from zones z
where st_intersects(z.geom, st_Buffer(ST_SetSRID(ST_Point(     2.336031, 48.863172), 3857),1));

It looks like the '1' in the st_buffer is being interpreted as degrees, I need to find geometries within n meters of a given point.

I did find a reference to a new function (st_Buffer_Meters) but that didn't seem to do anything different.


Solution

  • The actual query that ended up working was:

     select nom
     from zones s
     where ST_DWITHIN(Geography(ST_Transform(s.geom,4326)), ST_Point($1, $2) ,$3);`
    

    Where $1 is Longitude, $2 is Latitude and $3 is distance in meters.

    In addition I changed my imported data from SRID 3857 to SRID 4326

    Here's the gis.stackexchange question: https://gis.stackexchange.com/questions/118472/postgis-get-geometries-within-a-radius-of-n-meters-using-wgs84/118476#118476

    And here's the 'This has been asked before link https://gis.stackexchange.com/questions/77688/postgis-get-the-points-that-are-x-meters-near-another-point-in-meters