Reputation: 5192
I am new to this postGIS. My requirement is to retrieve data with the particular radius.IN my database i have the_geom(POINT).Now i have a query which will retrieve data within 2 DEGREE from the given point.
My query is:
select level4,level3
from xxxxxxx
where st_distance(the_geom,'SRID=4326;POINT(79.932018 12.513343)') < 2;
But i need to retrieve the points within particular kms or meters.. Help me to solve this.Thanks in advance..
Whether i have to have the column "Geography".I think now i have geometry column??
Upvotes: 3
Views: 3056
Reputation: 5671
You need to use the geography data type. Then you can use the ST_DWithin
function:
boolean ST_DWithin(geography gg1,
geography gg2,
double precision distance_meters);
You can use this query:
select level4,level3
from xxxxxxx
where st_dWithin(the_geom,'SRID=4326;POINT(79.932018 12.513343)', 2000);
See also this page in the postGIS manual.
Upvotes: 1