[postgis-users] WGS84 to meters

0 views
Skip to first unread message

Willy-Bas Loos

unread,
Sep 8, 2008, 10:09:09 AM9/8/08
to postgi...@postgis.refractions.net
Hi,

Suppose we want to store geometries that are all over the globe, and we want to calculate their surfaces and their mutual distances, in (square)meters.
The rounding of the globe may be disregarded.
Can it be done?


--
"Patriotism is the conviction that your country is superior to all others because you were born in it." - George Bernard Shaw

Nicolas Ribot

unread,
Sep 8, 2008, 11:14:01 AM9/8/08
to PostGIS Users Discussion
> Hi,
>
> Suppose we want to store geometries that are all over the globe, and we want
> to calculate their surfaces and their mutual distances, in (square)meters.
> The rounding of the globe may be disregarded.
> Can it be done?
>

Hi,
Yes for the distance, as Postgis provides both distance_sphere and
distance_spheroid functions (distance_spheroid is more accurate, taken
the "real" shape of earth into account, but takes a longer time to
execute.)
Distance is computed between points, not between geometries, so will
either have to take the centroid of your geometry, or compute the
distance for individual coordinates).

No for surfaces. You will have to project your data into a planar
projection system to do so (UTM for instance). This thread may be
useful in your case to find the correct UTM zone according to your
objects coordinates:

http://www.nabble.com/function-to-find-UTM-zone-SRID-from-POINT-td1772300.html

Nicolas
_______________________________________________
postgis-users mailing list
postgi...@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Robert Coup

unread,
Sep 8, 2008, 9:36:50 PM9/8/08
to PostGIS Users Discussion
On Tue, Sep 9, 2008 at 3:14 AM, Nicolas Ribot <nick...@gmail.com> wrote:
No for surfaces. You will have to project your data into a planar
projection system to do so (UTM for instance). This thread may be
useful in your case to find the correct UTM zone according to your
objects coordinates:

Untrue, the maths is just a little harder! And you need to assume the globe is a sphere (ala distance_sphere()):

If you're dealing with lat-lon "rectangles" you want something like this: 

If you're dealing with arbitrary polygons its a bit more complicated:

HTH,

Rob :)

Bruce Raup

unread,
Sep 8, 2008, 9:56:55 PM9/8/08
to PostGIS Users Discussion
If your data are globally distributed (as you said they are), then UTM
probably isn't the best choice. A global equal-area projection would
be better, in that you can use the same parameters regardless of where
on the globe you're working. I have a similar application, and use
Cylindrical Equal Area. I use something like (with an old version of
PostGIS -- I think the function names all start with ST_ now):

select sum(area(transform(glacier_polys,32767))) FROM glacier_polygons ...

Note that the EPSG code here is one I defined. I think the current
version of PostGIS might have CEA projection defined in some proper
location.

Bruce

> _______________________________________________
> postgis-users mailing list
> postgi...@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>

--
Bruce Raup
http://cires.colorado.edu/~braup/

Willy-Bas Loos

unread,
Sep 9, 2008, 5:43:06 AM9/9/08
to PostGIS Users Discussion

>A global equal-area projection would
>be better, in that you can use the same parameters regardless of where
>on the globe you're working.  I have a similar application, and use
>Cylindrical Equal Area.  I use something like (with an old version of
>PostGIS -- I think the function names all start with ST_ now):
>
>select sum(area(transform(glacier_polys,32767)))  FROM glacier_polygons ...


cool,thanks.
distance sphere is also working great.
I see that there is also an ST_length_spheroidI(nice, though .._sphere is missing).

I know how to calculate distances now, but for area calculation or buffering i still have to transform to a different coordinate system.
Using a single coordinate system for the whole globe is already a great improvement, but i still have to be cautious to use the right transformation for the calculation that i want to do.

Wouldn't it be great if GEOS (i mean postgis really) could do calculations for WGS84 (which would store anything "lossless") in meters?
We can already compute distances in meters, so why can't we do all calculations (area, buffer) in WGS84 ??

As for buffers, it should be possible to make a buffer_sphere and a buffer_spheroid, because distance calculations is all it takes (afaik).
If someone would invent a way to create an "area_sphere" and "area_spheroid", i would see no more need to store geometries in anything else than WGS84.

Any thoughts on that?

Cheers,

WBL



David William Bitner

unread,
Sep 9, 2008, 10:37:28 AM9/9/08
to PostGIS Users Discussion
Willy,

Yes it would be great if PostGIS natively dealt with Geodetic measurements.  This has been on many peoples wish lists for a long time.  Unfortunately, just because something is desired does not mean that there is either a developer "with the itch" or someone with funding.  As such a few of the simple cases for dealing with spherical calculations have been knocked off such as distance and length.  If this is somethat is very valuable too you, perhaps you might want to look into funding some of the work involved.

David

_______________________________________________
postgis-users mailing list
postgi...@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users




--
************************************
David William Bitner
Reply all
Reply to author
Forward
0 new messages