8 votes
Accepted

Why is the length of one degree in Turf 0.9988?

This seems to be the end result of an interesting conversion from radians to degrees. t.convertLength(Math.PI,"radians","degrees") 179.78993435469053 PI radians should be 180 degrees. Looking at the ...
Spacedman's user avatar
  • 59.2k
6 votes

What is approximate error of Pythagorean Theorem vs. Haversine Formula in measuring distances on sphere at various scales?

For a full and rigorous answer look to whuber's answer above. I'm going to answer in a more visual and basic way. The reason why planar/Pythagorean calculations are inappropriate is because the ...
Erik's user avatar
  • 309
6 votes

Calculating Latitude/Longitude X miles from point?

If you need a JavaScript solution consider these functions and this fiddle: var gis = { /** * All coordinates expected EPSG:4326 * @param {Array} start Expected [lon, lat] * @param {Array} ...
Jonatas Walker's user avatar
4 votes

What kind of margin of error can I expect in figuring distance?

Pre-Answers The word accuracy carries different meanings in Survey Engineering and in GIS even though both are related. In the former, it is explained here. In the latter, it was discussed here. ...
Ralph Tee's user avatar
  • 1,652
3 votes
Accepted

Calculating distances with PROJ4J

This function implements the Haversine formula (see the source code here - it is indeed not documented). The input parameters are geographical coordinates (double lon1, double lat1, double lon2, ...
julien's user avatar
  • 10.1k
3 votes

Calculating haversine versus checking latitude and longitude digits after decimal point?

Assuming that you are already handling exceptions at the edges of the system, i.e. knowing that (-179.9999 ; 0) is as close to (179.9999 ; 0) as (-179.9997 ; 0). Assuming also that you handle the ...
Gabriel De Luca's user avatar
3 votes
Accepted

Would nearest point using Geodesic distance and nearest point using Haversine distance be the same point?

For sure, "closest" will return different points, in general, for great-circle (what you call haversine) and geodesic distances. For a specific example, consider the set of points {A, B} where the ...
cffk's user avatar
  • 3,176
2 votes
Accepted

Vincenty's formulae to calculate in MySQL and PHP

With points as close as these we can ignore what type of spheroid the earth is and use the eqirectangular projection Pythagoras formula is all that is required. The following two functions are in PHP....
david strachan's user avatar
2 votes

Calculating Latitude/Longitude X miles from point?

I got this working in ObjectiveC. The key here is knowing that you need lat/lng points in radians and you need to convert them back to lat/lng after applying the equation. Also, know that distance and ...
BigCheesy's user avatar
  • 121
2 votes

st_distance returns different answer than haversine formula

The first issue is that you are using latitude-longitude coordinates, while they should be expressed as longitude-latitude. If you swap them, you will get the proper result. The second issue is that ...
JGH's user avatar
  • 38.3k
2 votes
Accepted

Retrieving Lat and Long positions for pixels in a neighborhood in Google Earth Engine

The problem was solved by checking again the code. The haversine function had a minimal mistake, where the correct is var a = p2.multiply(p3).add(p1); // a = p1 + p2 * p3 instead of var a = p2.add(...
José Lucas Safanelli's user avatar
2 votes

Compute difference in lon / lat when moving at angle

This is a problem in spherical geometry, like all midshipmen needed to learn in 17th century ;>) This site has actual calculating scripts, but also shows the formulae, with explanations if you want ...
ZanStrausz's user avatar
2 votes
Accepted

When calcuating distance between points on Earth why are my Haversine vs. Geodesic calculations wildy diverging?

I appreciate your code because it contributes to geodesy, by allowing to make some interesting analyzes in a practical way, regarding spherical approximations for the calculation of length of geodesic ...
Gabriel De Luca's user avatar
2 votes

When calcuating distance between points on Earth why are my Haversine vs. Geodesic calculations wildy diverging?

There was a matrix algebra error in the Haversine formula. I updated the code in the question. I am getting much better agreement between Haversine and geodesic now: On my actual dataset:
Bstampe's user avatar
  • 193
2 votes

About distance between two coordinates streets?

You can use an open source solution like GraphHopper. You can test the commercial demo here: https://graphhopper.com/maps/ but there is also a community version, which you can run on your own. ...
Michał Okulewicz's user avatar
2 votes
Accepted

Haversine accuracy worse when using geocentric radius vs average Earth radius

Ok I figured it out after some research. Instead of using the Geocentric radius I instead calculate the radius Use the “Radius of Curvature formula at azimuth α” formula from the paper (page 5): http:/...
Rob's user avatar
  • 21
2 votes

Haversine distance versus Euclidean on an eqc "equi-distance" projection

I recommend using the geodesic distance. geopy provides this functionality, so you don't have to code it up. This way, you avoid the guess work about the domain of applicability of your suggested ...
cffk's user avatar
  • 3,176
1 vote

Math error when trying to calculate the distance between two coordinates in python

Just running this in python it seems to calculate the distance without error, though the marseille to marseille distance is 0.0013 rather than 0. import numpy from math import acos, cos, sin, radians ...
rpr_mt's user avatar
  • 102
1 vote

How get distance in degrees to calculate buffers in AWS Athena?

In another search within the presto documentation I find this gem that gives me good approximate results.... Supporting geospatial computation on different SRID which formula is the following: ...
Cristián Vargas Acevedo's user avatar
1 vote

Haversine based distance transform

I would follow these steps: Create points from individual pixel's center, assign each pixel value and coordinate of its center to the corresponding point. Review this post. (rasterio, geopandas) ...
Kadir Şahbaz's user avatar
1 vote

Offset Latitude and Longitude by some meters accurately - Reverse Haversine

Use GeographicLib: from geographiclib.geodesic import Geodesic geod = Geodesic.WGS84 lat1 = 0 lon1 = 0 theta = 0 #direction from North, clockwise azi1 = theta - 90 #(90 degrees to the left) shift = ...
Gabriel De Luca's user avatar
1 vote

Generate a circle of coordinates around a point, but I'm getting an Oval

Another direct geometrical approach, without having to play with projections is to rely on libraries intended to do geodesics computation. The geographiclib is the go to solution for this. It has ...
LoneWanderer's user avatar
1 vote

Drawing circle of a fixed radius in meter, rounding error?

Possible Solution: const forceRadius = 5; const pointRes = getPointResolution(map.getView().getProjection(), 1, center); const mapUnit = forceRadius / pointRes; const radius = [center, [center[0] + ...
BR75's user avatar
  • 435
1 vote

Drawing circle of a fixed radius in meter, rounding error?

On possible solution would be to use turf.destination method from turf.js library to calculate the second point: var point1 = turf.point(ol.proj.toLonLat(center)); var point2 = turf.destination(point1,...
TomazicM's user avatar
  • 21.4k
1 vote

Calculate distance between consecutive GPS points for each id

I think this example code I made for you might help you. Expression: harvesine(!user_id!, !lat!, !lon!) Code Block: dic = {} def harvesine(user_id, lat2, lon2): global dic if user_id not ...
cabesuon's user avatar
  • 1,041
1 vote

Calculating haversine versus checking latitude and longitude digits after decimal point?

I refer you to this really good Q&A here at GIS Stack Exchange: Measuring accuracy of latitude and longitude?
muri's user avatar
  • 136
1 vote
Accepted

How to Specify Haversine when using Buffer Method in Shapely and how to get Haversine distance between two Shapely Point objects?

Instead of Haversine distance formula, you can use directly pyproj python module. For instance, for producing a 1000 m buffer (EPSG:32612) around this point (-112.171129818, 40.1731054115), EPSG:4326, ...
xunilk's user avatar
  • 28.4k

Only top scored, non community-wiki answers of a minimum length are eligible