Sample Header Ad - 728x90

How to make ST_DWithin to use meters for distance in Postgis?

0 votes
1 answer
543 views
I have already asked a similar question here: https://dba.stackexchange.com/questions/182839/find-the-nearest-geo-points-across-two-tables-with-postgis-or-without but now I am stuck around the correct geo-reference to calculate the distance in ST_DWithin. What I have did with my tables is creating a column geom in this way: ALTER TABLE my_table ADD COLUMN geom geometry(Point, 4326); update my_table set geom = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326); CREATE INDEX my_table_geom_idx ON my_table USING gist(geom); Using this setup will take the function ST_DWithin to use as distance parameter "degrees" instead of "meters". How can I set the geom to work with meters? Is this the right setup? ALTER TABLE my_table ADD COLUMN geom geometry(Point, 2163); update my_table set geom = ST_SetSRID(ST_MakePoint(longitude, latitude), 2163); CREATE INDEX my_table_geom_idx ON my_table USING gist(geom);
Asked by Randomize (1203 rep)
Aug 25, 2017, 07:54 AM
Last activity: Apr 14, 2025, 04:02 PM