I'm new to PostGIS so my question might sound silly.
Currently working with Points to represent geographical locations (with latitude and longitude only) and was wondering how I can use [ST_DWithin][3]
with meters as a unit.
I can't find the right way and been lost in documentation trying to solve this issue.
You need to make sure that your points are geography
rather than geometry
, as explained in the manual.
So you want a query like:
SELECT s.gid, s.school_name
FROM schools s
LEFT JOIN hospitals h ON ST_DWithin(s.geom::geography, h.geom::geography, 3000)
WHERE h.gid IS NULL;