[postgis-users] decimal degrees -> miles?
Dave Blasby
dblasby at refractions.net
Mon Aug 26 10:24:39 PDT 2002
Alex Rice wrote:
>
> Hi, does PostGIS have a function for converting decimal degrees
> to miles? I'm using a -1 projection and my data is in decimal
> degrees.
There are some functions that do calculations on ellipsoids. Otherwise,
I would just transform() the data to a rectangular spatial referencing
system, then do a length().
From the help files:
---------------------
length_spheroid(geometry,spheroid) ::
Calculates the length of of a geometry on an elipsoid. This is useful if
the coordinates of the geometry are in latitude/longitude and a length
is desired without reprojection. The elipsoid is a separate database
type and can be constructed as follows:
SPHEROID[<NAME>,<SEMI-MAJOR AXIS>,<INVERSE FLATTENING>]
Eg:
SPHEROID["GRS_1980",6378137,298.257222101]
An example calculation might look like this:
SELECT
length_spheroid(
geometry_column,
'SPHEROID["GRS_1980",6378137,298.257222101]'
)
from geometry_table;
length3d_spheroid(geometry,spheroid) ::
Calculates the length of of a geometry on an elipsoid, taking the
elevation into account. This is just like length_spheroid except
vertical coordinates (expressed in the same units as the spheroid axes)
are used to calculate the extra distance vertical displacement adds.
----------------------
So, you could:
SELECT
length_spheroid(
'LINESTRING(x1 y1, x2 y2)' ,
'SPHEROID["GRS_1980",6378137,298.257222101]'
)
;
OR
SELECT
length( transform(setSRID('LINESTRING(x1 y1, x2 y2)',
<latlong>),<rectangular>) ) ;
where latlong - SRID in the spatial_ref_system table of the latlong
projection
rectangular - SRID in the spatial_ref_system table of an
appropriate projection
NOTE: the results are probably in meters (if you use a standard
ellipsoid definition or a meters projection), so you'll have to convert
meters to miles.
More information about the postgis-users
mailing list