# Distances are different by ~100-200m

I'm measuring distance of 2 points on Google Map and then in my program converting them into ECEF using this formula. Then using Pythagorean theorem to calculate distance between those 2 points. Difference is about 100-200m, which is fairly big for what I am doing. In my program I use double for precision.

Big question will be what method Google is using in order to calculate distance between 2 points?

Update, example:

Lon/Lat : 44.50310895983847,40.16009701404741 and 44.50151117520584,40.15672510042466. Google Earth says it's 400m.

After converting to ECEF I get 3482269.0815067333, 2938590.6893090927 and 3482536.9833229352, 2938466.2491839984. I measure distance of 276.99011m

• Please give an example of the points, your distance, and Google's distance. – Ross Millikan Nov 7 '12 at 23:25
• ECEF is cartesian. Are you neglecting the curvature of the earth? – Emily Nov 7 '12 at 23:35
• Yes I know it is Cartesian. I am calculating using the formula in my original post, which I believe considering that earth is elliptical. – Pablo Nov 7 '12 at 23:39
• This site may help you: movable-type.co.uk/scripts/latlong.html – NoChance Nov 8 '12 at 0:40
• With $\Delta \phi = 0.003372$ I get the North-South distance as $6378137*0.003372*\frac \pi{180}\approx 375 m$ and $\Delta \lambda=0.0016$ gives EW as $6378137*0.0016*\cos (40.1584^\circ)\frac \pi{180}\approx 136 m$using a sphere, which supports the Google – Ross Millikan Nov 8 '12 at 0:51

The Spherical Law of Cosines says \begin{align} \cos\left(\frac{90^\circ}{10000\text{ km}}\text{dist}\right) &=\sin(\text{lat}_1)\sin(\text{lat}_2)+\cos(\text{lat}_1)\cos(\text{lat}_2)\cos(\Delta\text{lon})\\ &=\cos(\Delta\text{lat})-\cos(\text{lat}_1)\cos(\text{lat}_2)(1-\cos(\Delta\text{lon}))\tag{1} \end{align} Using the approximation $\cos(x)=1-\frac12x^2$ when $x$ is small yields $$\left(\frac{90^\circ}{10000\text{ km}}\text{dist}\right)^2 \stackrel.=\Delta\text{lat}^2+\cos^2(\text{lat})\Delta\text{lon}^2\tag{2}$$ for small values of $\Delta\text{lat}$ and $\Delta\text{lon}$.
We have \begin{align} \Delta\text{lat}&=0.0033719136227^\circ\\ \Delta\text{lon}&=0.0015977846327^\circ\\ \cos(\text{lat})\Delta\text{lon}&=0.0012211298208^\circ \end{align} With these values, I get $\text{dist}\stackrel.=398\text{ m}$.