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

Craig Miller craig.miller at spatialminds.com
Wed Aug 17 11:26:34 PDT 2005


Brent I have some C++ code to calculate great circle distance on the
ellipsoid if you want it.  You could pretty easily right a command line tool
that has zero dependencies if you are OK with fixing it to WGS84.

--Craig


-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Brent
Wood
Sent: Wednesday, August 17, 2005 11:08 AM
To: PostGIS Users Discussion
Subject: RE: [postgis-users] deriving distance between lat/long points.

--- 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;"

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





More information about the postgis-users mailing list