Geospatial - GIS

Scripts for complex calculations

Movable type scripts 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)

haversine formula 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

Golgi Alvarez

Writer, researcher, specialist in Land Management Models. He has participated in the conceptualization and implementation of models such as: National Property Administration System SINAP in Honduras, Management Model of Joint Municipalities in Honduras, Integrated Cadastre-Registry Management Model in Nicaragua, Territory Administration System SAT in Colombia . Editor of the Geofumadas knowledge blog since 2007 and creator of the AulaGEO Academy that includes more than 100 courses on GIS - CAD - BIM - Digital Twins topics.

Related Articles

Leave a comment

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

Back to top button