[postgis-users] very inaccurate distance using "distance_spheroid" on geometric coordinates

hzerres at aol.com hzerres at aol.com
Thu Oct 18 07:19:02 PDT 2007


Hi,

i am new to the list and to postgis. I hope i can
explain my problem to you guys.

I have been making tests with postgis and got a
list of the lat/lon coordinates of major cities in
the world. I imported them as Points into a table
and wanted to compute the distance between them.

For example:

select * from geodaten where id='1' or id='2'

 id |  lat   |  lon  |                    geom
                |  name  | geoproj
----+--------+-------+--------------------------------------------+--------+---------
  1 | 50.783 | 6.083 |
01010000004E62105839644940A245B6F3FD541840 | AACHEN |
  2 | 48.833 |  10.1 |
0101000000B4C876BE9F6A48403333333333332440 | AALEN  |

The following Sql-statement tells me i got
493,504km between the cities:

select id,distance_spheroid( (select geom from
geodaten where id='1'), geom,
'SPHEROID["WGS_1984",6378137,298.257223563]' ) as
dist from geodaten where id='2'

But thats wrong. It should be 360 km.

I tested if i imported the points corrct, and i did.

select id, asText(geom) from geodaten where id='1'
or id='2';
 id |       astext
----+---------------------
  1 | POINT(50.783 6.083)
  2 | POINT(48.833 10.1)

Has anybody a clue of what i am doing wrong?

Thanks for helping.

Hape






More information about the postgis-users mailing list