[postgis-users] WGS-84 coordinates in geometry

Sidney Cadot sidney.cadot at jigsaw.nl
Mon Sep 24 12:33:29 PDT 2007


Dear all,

Being a complete newcomer to GIS, I have what may well be a rather simple
problem.

Given that I have two WGS-84 points: (5 degrees East, 52 degrees North); and
(6 degrees East, 56 degrees North), sitting at altitude zero on the
ellipsoid surface. I want to put objects with these sort of coordinates in a
PostGIS database.

Now I was expecting that I could just represent them as points in a selected
SIR (4326 corresponds to standard WGS-84, I believe) using
latitude/longitude values.

Following this, I would have expected to be able to find their distance over
the WGS-84 ellipsoid as follows:

SELECT ST_Distance(
    GeomFromText('POINT(5.0 52.0)', 4326),
    GeomFromText('POINT(6.0 56.0)', 4326) );

which I sort of expected to return the distance in meters between those two
points over the surface of the WGS-84 ellipsoid, which should yield a value
of approx. 450009.761 meters.

Alas, I get back a value of 11.045...., which is the square root of 122,
which is simply the euclidean distance between (5 52) and (6 56).

Given this, my question is as follows: is my suspicion correct that POINT()s
and other geometrical objects assume a flat (euclidean) surface? Should I
first transform my WGS-84 (latitude,longitude) coordinates to a flat
(euclidean) coordinate system using a map projection?

If so, what would be the easiest way to do this transformation within
Postgres/Postgis? To put it in concrete terms: which query would start with
the values 5, 52, 6, and 56 (to be interpreted as WGS-84
latitude/longitudes), and yield the value 450009.761 (their distance in
meters)? Is this even possible?

As a last question: if Postgis handles euclidian geometry only, does this
also mean that things like intersection tests etc. are performed on the
projected (2D) representation of the geometry?

For example, in correct ellipsoid geometry, a "straight line" (geoid) on the
WGS-84 ellipsoid from (lat=45,lon=0) to (lat=45,lon=90) should intersect the
"straight line" (geoid) from (lat=45.000001, lon=45) to (lat=89, lon=45).
Can PostGIS help to handle such cases correctly?


Any help is much appreciated.





More information about the postgis-users mailing list