2
votes

I need to create a circle around a point (lon,lat) which is approximately X meters in radius.

The point is generated via the equivalent of geomFromEwkt('SRID=1;POINT(lon lat)').

I am aware of postgis' buffer or st_buffer function, however am unsure how to translate the distance (meters) to the "units of the Spatial Reference System of this Geometry".

doc "Calculations are in units of the Spatial Reference System of this Geometry"

3
i also understand that this might give a slight elipse shape but i just need an approximate shape so i'm not too concerned about that. - pstanton

3 Answers

2
votes

The elliptical shape will be more and more pronounced the further north you get. If you're on PostGIS 1.5, do geometry(ST_Buffer(GeogFromText('POINT(lon lat)'),100)) to do the buffering in spherical space and get a correct answer regardless of latitude.

1
votes

a colleague filled me in on a approx calculation he uses:

buffer("location", radius / 110000 * abs(cos(radians(lat))));

where location is the point geometry.