[postgis-users] function to convert meters into degrees without reprojections

Paul Ramsey pramsey at refractions.net
Fri Mar 30 11:03:28 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.

I wonder if a quick utility function could make this "kind" of thing 
easier...

Basically, a 
to_local_planar(geom_to_convert,geom_to_reference,'MAGICSTRING')

the function would use geom_to_reference to set up the bounds of the 
transform, and the MAGICSTRING to choose the TYPE of transform (albers, 
tm, stereographic, etc).

It would have two shorter forms with defaults:

to_local_planar(geom_to_convert, geom_to_reference) which just uses 
transverse mercator
to_local_planar(geom_to_convert) which uses the input geometry as a 
reference geometry

And of course, there would be the inverse, from_local_planar

This would allow

select from_local_planar(buffer(to_local_planar(the_geom), 100.0))

Or... we could wrap this stuff all up to do it "automagically" in the 
cases where SRID = 4326... and only the people who exercised it outside 
of the box (around the poles, say) would be duly punished.

P


-- 

   Paul Ramsey
   Refractions Research
   http://www.refractions.net
   pramsey at refractions.net
   Phone: 250-383-3022
   Cell: 250-885-0632



More information about the postgis-users mailing list