I am calculating distance in meters between two lat long values -
40.1844441 -77.2252771 and
40.319166 -76.7880552
I tested the distance between these two points in below two web sites -
http://www.nhc.noaa.gov/gccalc.shtml and
http://www.movable-type.co.uk/scripts/latlong.html
Both of these web sites return approximately 40014 meters.
So, I uses SQL server's GEOGRAPHY data type to calculate the distance between these two points again and it returns 48927 meters. It is a huge difference to me.
Below is my code and any suggestion is appreciated.
declare @latlong1 GEOGRAPHY
declare @latlong2 GEOGRAPHY
DECLARE @distance float
set @latlong1 = GEOGRAPHY::STGeomFromText('POINT(40.1844441 -77.2252771)', 4326)
set @latlong2 = GEOGRAPHY::STGeomFromText('POINT(40.319166 -76.7880552)', 4326)
SET @distance = @latlong1.STDistance(@latlong2)
SELECT @distance -- this returns 48927 meters