I am trying to find the distance between two points (in meters and not degrees) using GIS Tools for Hadoop by ESRI. The ST_Length provides distance in degrees and hence I used the ST_GeodesicLengthWGS84 function. However, I noticed that the distances are not what I would expect to see. Below are the queries I tried:
SELECT ST_GeodesicLengthWGS84(ST_SetSRID(ST_Linestring(0.0,0.0, 0.3,0.4), 4326))/1000;
SELECT ST_GeodesicLengthWGS84(ST_SetSRID(ST_Linestring(40.773773, -73.872307, 40.973773, -73.772307), 4326))/1000;
SELECT ST_GeodesicLengthWGS84(ST_SetSRID(ST_Linestring(40.773773, -73.872307, 33.944115, -118.40377), 4326))/1000;
I also used the distance calculator to check the distance (http://andrew.hedges.name/experiments/haversine/) and also google maps for directional reference (Google is a road distance, so it cannot be less than the distance from the above queries)
Here are the results I see for the three queries:
1) 55.42 (55.615 KM from distance calculator)
2) 12.77 (23.73 KM from distance calculator and 33.2 KM from google maps)
3) 4962.36 (3966.188 from distance calculator and 4536 KM from google maps)
Can someone tell me in case I misunderstood the use of this formula? And what would be the right way to get the distance in meters/KM?
ST_Linestring
may be expecting (X, Y) so try swapping your latitude and longitude values.