[postgis-users] function to convert meters into degrees without reprojections
Brent Wood
pcreso at pcreso.com
Fri Mar 30 13:44:18 PDT 2007
THEETEN Franck wrote:
> Hi Everybody,
>
> A few days ago I had a problem with projection units.
> I had a series of points in WGS 84 (with a projection which uses decimal
> degrees as unit) and I needed to trace a circle around them, with a
> radius specified in meter.
> The 'Buffer()' function from the postgis library allows the definition
> of a circle around a geometry, but it didn't work in this situation
> because the radius value must be expressed in the same unit as the
> reference point.
> I found on the Postgis mailing list some solutions which used the
> definition of a constant value allowing conversions between degrees and
> meters.
> But it was an unsatisfactory answer for my problem because the result of
> this conversion varies with the latitude.
Sorry if I've missed something, but why is an explicit reprojection on the fly
not a viable solution? There is no need to store any reprojected data.
I've generated millions of buffers on lines & points stored in EPSG:4326 by
(from memory) something like:
update <table> set buffer_geom=
transform(buffer(transform(geom,27201),<dist>,<n>),4326)
where 27201 is a custom equal-area projection for my part of the world & you
can set the required dist & n values for buffer to meet your requirements.
Of course, the resulting circles are actually rendered as ellipses under
lat/long, which they should be.
I guess if such reprojections are inappropriate for some reason, given that the
longitudinal (X) distance varies with the cosine of the latitude (Y), you could
still apply a constant value, but apply a modifier based on
cos(Y(centroid(geom))) (omit centroid if only points are to be used) to the
constant to make some sort of allowance for latitude. Not as precise, but
perhaps good enough in your case?
Cheers,
Brent Wood
More information about the postgis-users
mailing list