Vertica Place - Difference between ST_Distance and google distance

Hello, I would like to understand the difference between google map and ST_Distance calculation.

 

case: distance between Milan and Bari with google maps is: 786 km with azimut 125 degrees

Milan geo coordinates (degrees) are latitude 45 27 50 and Longitude 9 11 31, converted to decimal is: (45.463889, 9.191944)

Bari geo coordinates (degrees) are latitude 41 6 41 and longitude 16 51 19, converted to decimal is: (41.111389 3 16.885278)

 

So I execute the select as follow:

SELECT ST_Distance(ST_GeographyFromText('POINT(45.463889 9.191944)'),    ST_GeographyFromText('POINT(41.111389 16.885278)'));

with result: 976591.545506267 meters so: 976 kilometers.

 

Which other parameters do I need to configure? What's wrong with my select? 

 

many thanks for any suggestion,

Vivian.

Comments

  • PanPan Employee

    Hello, Vivian

     

    Thank you for using Place.

     

    The format for WKT here is (x,y) = (long, lat) ;

     

    So you have to reverse the long and lat value in your WKT. Also, to use WGS84 coordinate system, you have to use parameter spheriod=true, otherwise it will calculate based on perfect sphere.

     

     

    WGS84 result:

     

    SELECT ST_Distance(ST_GeographyFromText('POINT(9.191944 45.463889)'), ST_GeographyFromText('POINT(16.885278 41.111389)') using parameters spheroid=true);
    ST_Distance
    ------------------
    789127.852937305
    (1 row)

     

    Perfect sphere result:

    SELECT ST_Distance(ST_GeographyFromText('POINT(9.191944 45.463889)'),    ST_GeographyFromText('POINT(16.885278 41.111389)'));
       ST_Distance  
    -----------------
     788061.60163958
    (1 row)

     

    Regards.

    Pan

  • zunzun Community Edition User

    Hi, I'm also running into a similar issue with geospatial function being in-accurate. I'm using Stv_geometrypoint and St_distance, and have reversed lat/long as suggested above, but still obtain incorrect results.

    For example:
    --lat/long of empire state building new york: (40.74819191258412, -73.98573903191816)
    --lat/long of Good Smaritan Hospital in LongIsland NYC: (40.69412102658633, -73.29518084490165)
    --distance between empire state & Good Smaritan Hospital == 58.58KM from Google Maps

    SELECT public.St_distance(public.Stv_geometrypoint(-73.98573903191816, 40.74819191258412), public.Stv_geometrypoint(-73.29518084490165, 40.69412102658633))
    --Result: 0.692671834542238
    -- 0.692671834542238 * 111KM = 76.88KM

    76.88KM is not even close to 58.58KM.

    What am I doing wrong?

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file