Easy and Hard Map Based on Projections

When using a projected coordinate system, it turns out you can calculate distance with a very simple lambda function. Beats that ugly haversine formula you have to use with World Geodetic System 1984.

lambda xa, ya, xb, yb : math.sqrt((xb-xa)**2 + (yb-ya)**2)

Here is the equalivent with WGS 84 (written as a Lambda):

lambda xa, ya, xb, yb: 2*asin(sqrt(sin(radians(xb – xa) /2)**2 + cos(radians(xa))*cos(radians(xb))*sin(radians(yb – ya)/2)**2 )) * 3959.87433

Leave a Reply

Your email address will not be published. Required fields are marked *