[postgis-users] ST_distance in meters

1,568 views
Skip to first unread message

lomarod

unread,
Jan 22, 2010, 6:17:40 AM1/22/10
to postgi...@postgis.refractions.net

Hi,

I have a table "tableA" with the column "colB" and "colC" type geometry.

tableA.colB = geometryfromtext('POINT('-19.922488 -43.9367')',4326)
tableA.colC = geometryfromtext('POINT('-19.926357 -43.934223')',4326)

Using google earth or google maps, a have the distance between this two
points in 500 meters.

When I execute the query
select st_distance(tableA.colB, tableA.colC) from tableA my result is
0,004593984...

How can I have the same result as google maps ?
What am I doing wrong ?


--
View this message in context: http://old.nabble.com/ST_distance-in-meters-tp27271750p27271750.html
Sent from the PostGIS - User mailing list archive at Nabble.com.

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

Suhr, Ralf

unread,
Jan 22, 2010, 6:39:42 AM1/22/10
to PostGIS Users Discussion
ST_Distance_Spheroid( pointa, pointb, 'SPHEROID["WGS 84",6378137,298.257223563]');

Gr Ralf

-----Ursprüngliche Nachricht-----
Von: postgis-us...@postgis.refractions.net [mailto:postgis-us...@postgis.refractions.net] Im Auftrag von lomarod
Gesendet: Freitag, 22. Januar 2010 12:18
An: postgi...@postgis.refractions.net
Betreff: [postgis-users] ST_distance in meters

ibrahim saricicek

unread,
Jan 22, 2010, 6:40:39 AM1/22/10
to PostGIS Users Discussion
Hi;

For 4326 projection distance unit is in degrees.
Google maps use 900913 projection code, and units for this projection.
To get the same distance calculation; firstly add 900913 projection to spatial_ref_sys table.

Then use this query

select st_distance(st_transform(tableA.colB,900913),st_transform(tableA.colC,900913))

Regards..
IBO..

Oscar Zamudio

unread,
Jan 22, 2010, 12:40:43 PM1/22/10
to PostGIS Users Discussion
I couldn't find 900913 in the Spatial Reference List. Does anybody know which one of the following projections uses Google Maps?
I'm also trying to compare with Google Maps my results of measuring distances reprojecting my original SRID-4326 data to some UTM projection but I don't know what is the right one.
Oscar

Mike Toews

unread,
Jan 22, 2010, 12:52:04 PM1/22/10
to PostGIS Users Discussion
Oscar Zamudio wrote:
> I couldn't find 900913 in the Spatial Reference List. Does anybody
> know which one of the following projections uses Google Maps?

900913 isn't any "official" spatial reference number, in fact it is
leetspeek for "Google" (where 9=g, etc.)

A good reference I found is here:
http://trac.openlayers.org/wiki/SphericalMercator

-Mike

Nicolas Ribot

unread,
Feb 1, 2010, 12:15:24 PM2/1/10
to PostGIS Users Discussion
> 900913 isn't any "official" spatial reference number, in fact it is
> leetspeek for "Google" (where 9=g, etc.)
>

:))) Huge.

We were wondering how this code was choosen, so big.
Have our answer, thanx.

Nicolas

Reply all
Reply to author
Forward
0 new messages