[postgis-users] deriving distance between lat/long points.

Brent Wood pcreso at pcreso.com
Wed Aug 17 11:08:20 PDT 2005


--- Ethan Alpert <ealpert at digitalglobe.com> wrote:

> 
> Is the function distance_spheroid not available in v0.8? This does the
> trick without reprojecting the data.
> 
> -e

It is, but as in the example below, I continue to get NaN results with what I
think are valid input parameters:

Any suggestions? Is it likely that other spheroids my work better? I assumed it
would be fine using the spheroid of the input data projection. 


Thanks,

  Brent


(From the original post)

> I have not been able to get distance_spheroid or length_spheroid to
> work, & distance_sphere doesn't exist in postgis.sql. I have no say on
> the versions to be installed, and can but hope for an upgrade someday.
> 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

> 
> Parameters:
> Line:        GeometryFromText('LINESTRING(160 -45,180 -45)', 4326)
> Start point: GeometryFromText('POINT(160 -45)', 4326)
> End point:   GeometryFromText('POINT(180 -45)', 4326)
> Spheroid = SPHEROID["WGS_1984",6378137,298.257223563]
> SRID:      54027
> 
> distance(point,point)
> 4616.85
> distance_spheroid(point, point, spheroid)
> NaN
> [woodb at otter ~]$ arc_dist -45 160 -45 180
> 
> Parameters:
> Line:        GeometryFromText('LINESTRING(160 -45,180 -45)', 4326)
> Start point: GeometryFromText('POINT(160 -45)', 4326)
> End point:   GeometryFromText('POINT(180 -45)', 4326)
> Spheroid = SPHEROID["WGS_1984",6378137,298.257223563]
> SRID:      54032
> 
> distance(point,point)
> 1747.37
> distance_spheroid(point, point, spheroid)
> NaN
> [woodb at otter ~]$
> 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


& the script code:             

> 
> echo "distance_spheroid(point, point, spheroid)"
> psql $DB -U woodb -q -A -t -c "select (distance_spheroid($START , $END,
> '$SPHEROID' )/1000)::decimal(9,2) as Km;"




More information about the postgis-users mailing list