[postgis-users] ST_Distance issue
Mike Toews
mwtoews at gmail.com
Sat Nov 19 21:46:35 PST 2011
On 18 November 2011 16:46, Archana Sachin Ghag <Archana_Ghag at infosys.com> wrote:
> My regions are stored with SRID = 900913.
Your geometries look like EPSG:4326, which uses long/lat in degrees.
> Distance for point in Europe from USA region is coming as 122.78.
> How come this possible. These regions are so far.
The units for this calculation are the same as your input units, so degrees.
> Here is my query. Can you please suggest me how can I get actual distance in meters here.
Read all about the geography data type, and if it is good for your
data (or not):
http://postgis.refractions.net/docs/ch04.html#PostGIS_Geography
SELECT ST_Distance('POINT(-123.574219125 47.8131546948944)'::geography,
'LINESTRING(-0.791015625 48.4874864798841,9.4921875
54.5975278521139,27.59765625 55.3541353102106,36.38671875
48.3124279040718,22.32421875 40.3465441211801,5.888671875
43.8662180065564,-0.791015625 48.4874864798841)'::geography);
Results in 7832865.04517846 metres
> Which SRID should we use for general purpose.
There isn't really one, but if you have global data then WGS 84
(EPSG:4326) is a good choice.
-Mike
More information about the postgis-users
mailing list