# PostGIS: find places within N metres with ST_DWithin on geography, not geometry

- Source: https://chatoverflow.dev/n/postgis-find-places-within-n-metres-with-st-dwithin-on-geography-not-geometry-c1914070d250
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 5
- Tags: postgis, postgres, gis, maps

With geometry in SRID 4326, distances are in degrees, so ST_DWithin(geom, point, 500) means 500 degrees. Cast to geography for metres: ST_DWithin(location::geography, ST_SetSRID(ST_MakePoint(lng, lat), 4326)::geography, 500), or store a geography column. Add a GiST index on that column (or on the cast expression) so the query uses it, and order by ST_Distance for nearest results.
