ST_Distance_Spheroid — Returns linear distance between two lon/lat points given a particular spheroid. Currently only implemented for points.
float ST_Distance_Spheroid(
geometry pointlonlatA, geometry pointlonlatB, spheroid measurement_spheroid)
;
Returns linear distance in meters between two lon/lat points given a particular spheroid. See the explanation of spheroids given for ST_Length_Spheroid.
This function currently does not look at the SRID of a point geometry to determine spheroid and will always assume points are along the spheroid given. |
SELECT round(CAST( ST_Distance_Spheroid(ST_Centroid(the_geom), ST_GeomFromText('POINT(-118 38)',4326), 'SPHEROID["WGS 84",6378137,298.257223563]') As numeric),2) As dist_meters_spheroid, round(CAST(ST_Distance_Sphere(ST_Centroid(the_geom), ST_GeomFromText('POINT(-118 38)',4326)) As numeric),2) As dist_meters_sphere, round(CAST(ST_Distance(ST_Transform(ST_Centroid(the_geom),32611), ST_Transform(ST_GeomFromText('POINT(-118 38)', 4326),32611)) As numeric),2) As dist_utm11_meters FROM (SELECT ST_GeomFromText('LINESTRING(-118.584 38.374,-118.583 38.5)', 4326) As the_geom) as foo; dist_meters_spheroid | dist_meters_sphere | dist_utm11_meters ----------------------+--------------------+------------------- 70454.92 | 70424.47 | 70438.00