[postgis-users] length_spheroid problem

Wood Brent pcreso at pcreso.com
Wed Apr 28 15:22:58 PDT 2004


Hmm....

I'm not sure what is going on with length_spheroid...


The SRID I'm using is 4326. My longs are around 173 to 185, lats from -21 to
-44.

Running your example works fine. If I change the hard coded values from (0 0, 1
1( to (178 -43, 179 -43) I get:

env2003=# select length_spheroid('LINESTRING(0 0,1 1)',
'SPHEROID["WGS84",6378137,298.25728]');
 length_spheroid
------------------
 156899.568401239
(1 row)

env2003=# select length_spheroid('LINESTRING(178 -43, 179 -43)',
'SPHEROID["WGS84",6378137,298.25728]');
 length_spheroid
-----------------
             NaN
(1 row)

I expected the latter to return a reasonable value.

If (to translate W away from 180 deg issues, which should not change the
length, & convert to mercator northings & eastings with a generic WGS84
mercator projection, I get:


select the_geom, length(transform(translate(the_geom, -100,0,0),54004)) from
event limit 10;
                         the_geom                          |      length
-----------------------------------------------------------+------------------
 SRID=4326;LINESTRING(174.195 -43.6233,174.17667 -43.8983) | 42287.2571019774
 SRID=4326;LINESTRING(173.91667 -43.95,174.03333 -43.7)    | 40574.1584130796
 SRID=4326;LINESTRING(174.195 -43.6233,174.17667 -43.8983) | 42287.2571019774
 SRID=4326;LINESTRING(174.195 -43.6233,174.17667 -43.8983) | 42287.2571019774
 SRID=4326;LINESTRING(174.18667 -43.9166,174.18 -43.65)    | 40970.0579850281
 SRID=4326;LINESTRING(173.91667 -43.95,174.03333 -43.7)    | 40574.1584130796
 SRID=4326;LINESTRING(173.91667 -43.95,174.03333 -43.7)    | 40574.1584130796
 SRID=4326;LINESTRING(180.15 -44.25,180.15 -44.3)          | 7746.97040687501
 SRID=4326;LINESTRING(174.18667 -43.9166,174.18 -43.65)    | 40970.0579850281
 SRID=4326;LINESTRING(174.18667 -43.9166,174.18 -43.65)    | 40970.0579850281
(10 rows)



If I have trouble getting distance_spheroid to work, can anyone confirm these
results as being correct (within 1% or so is fine)? 

I'm assuming translate uses coordinate units & distance returns meters.


Cheers,

  Brent Wood





More information about the postgis-users mailing list