[postgis-users] earth distance via projections
dblasby at refractions.net
Tue Apr 15 09:14:37 PDT 2003
> proj +proj=tpeqd +lon_1=21d0 +lat_1=52d15 +lon_2=4d54 +lat_2=52d21
> This PROJ command converts all input points to x/y-coordinates from
> which correct distances can be computed to either Warsaw or Amsterdam.
> This method has been used by Bell telephone to calculate costs for
> long distance calls.
> Can this be done with PostGIS? PostGIS can transform coordinates using
> standard EPSG projection parameters, but can it also do
> transformations with user defined parameters, like lat/lon above?
I was going to suggest this, but its a bit more complex - you have to
use some lower-level projection routines:
-> tranform_geometry( <geom>, <proj4 string - input projection>,
<proj 4 string - output projection>, <new SRID>)
Plus you have to build the proj4 string up from your input points (use
the concatenate operator (||) and the X(point), Y(point) functions).
> PS: PostgreSQL's contrib directory has an "earthdistance" function,
> which computes distances over a grand circle. Does anyone know how
> exact this is, compared to a projected computation?
I it does distances on a sphere not an ellipse. If its okay to use that
approximation, the routines are probably pretty quick and easy to use.
More information about the postgis-users