Geospatial - GIS
Scripts for complex calculations
Movable Type Scripts is a website that offers complex codes in Javascript and some in excel, for applications in geomatics.
Among the most useful are:
- Calculation of a distance from two coordinates (lat / long)
Calculates the shortest distance using the formula Haversine, it only requires the coordinates of the origin and destination points to be entered. Not only does it generate the result of the calculations but the code is written, a hyperlink to visualize the vector in Google Earth and the formula in excel.
This is the literal formula:
d = acos (without (lat1) .sin (lat2) + cos (lat1) .cos (lat2) .cos (long2-long1)), R
This is the JavaScript code:
var R = 6371; // km var d = Math.acos (Math.sin (lat1) * Math.sin (lat2) + Math.cos (lat1) * Math.cos (lat2) * Math.cos (lon2-lon1)) * R;
Here is the formula in Excel:
=ACOS(SIN(Lat1)*SIN(Lat2) +COS(Lat1)*COS(Lat2) *COS(Lon2-Lon1))*6371
Additionally you can see the codes for calculations such as:
- Course calculation
- Middle point
- Coordinates of the destination from a source and course
- Browser's Pursuit
- Conversion between degrees / minutes / seconds and decimal degrees
Take a look, the data are very useful for those who develop web applications, because it has the written codes
Vía: Anieto2k