So how do I write a query to get all rows within X meters of a certain lat/long coordinate?
I tried looking into the docs, but it's super confusing, ideally I just want to write
SELECT *
FROM locdat
WHERE ST_DWithin(ST_MakePoint(-71.1043443253471, 42.3150676015829),2000, true )
but I don't understand anything of the syntax they use in the docs or something like select ST_MakePoint(loc_point) from locdat won't work either.
loc_point is data like (54.66965,20.64888) of type text.
geometrytogeographyso thatST_DWithinuses geodesic distance of 2000 meters, not Cartesian distance of 2000 degrees (or doesn't simply returnfalsebecause the SRIDs are incompatible). Eventually you may have to deal with a covering index , but only if you have a lot of rows. – Vince Mar 14 '20 at 12:03SELECT ST_Distance(ST_SetSRID(ST_MakePoint(-71.1043, 42.3151),4326)::geography, ST_SetSRID(ST_MakePoint(54.6697,20.6489),4326)::geography)returns11095628.2meters (which is larger than 2km) – Vince Mar 14 '20 at 13:28