3 ms·
Why do you use haver-sine over geodesic or reprojection? I’ve been doing the reprojection thing, projecting coordinates to a “local” CRS, for previous projects
by wodenokoto 1y ago
Why do you use haver-sine over geodesic or reprojection?
I’ve been doing the reprojection thing, projecting coordinates to a “local” CRS, for previous projects mainly because that’s what geopandas recommend and is built around, but I am reaching a stage where I’d like to calculate distance for objects all over the globe, and I’m genuinely interested to learn what’s a good choice here.
- deleted 1y ago[deleted]
- code_biologist 1y agoJust an app dev, not a geospatial expert, but reprojection always seemed like something a library should handle under the hood unless one has specific needs. I'm used to the ergonomics / moron-proofing of something like Postgis' `ST_Distance(geography point1, geography point2)` and it gives you the the right answer in meters. You can easily switch to spherical or Cartesian distances if you need distance calculations to go faster. `ST_Area(geography geog)` and it gives you the size of your shape in square meters wherever on the planet.
- dmillar 1y agoWhat the "right answer" is will vary widely on application and analyst. That's one reason there are so many coordinate ref systems. If you keep everything in 3857, you'll get answers in ~meters, but whether that's "right" depends on where and how large the distance or geom is and what your precision threshold is. So, really, everyone's needs are necessarily "specific."
- colkassad 1y agoLook into Vincenty [1] or Karney (for a more robust solution) [2]. Vincenty should be good enough for most use cases. [1] https://en.wikipedia.org/wiki/Vincenty's_formulae https://en.wikipedia.org/wiki/Vincenty's_formulae [2] https://github.com/pbrod/karney https://github.com/pbrod/karney
- wenc 1y agoReprojection is accurate locally but inaccurate at scale. Geodesics are the most accurate (Vincenty etc) but are computationally heavy. Haversine is a nice middle ground.
- wodenokoto 1y agoBut is it actually inaccurate at scale? I get that drawing a projection is inaccurate at scale, but if I do all my calculation as meters north/south and east/west of 0,0 on the equator, won’t all my distance calculations be correct? Like 5.000.000 east and 0 m north is 5.000km from the origin. I cannot see how that could ever become inaccurate as I move further away. Where is the inaccuracy introduced? When I reproject back to coordinates on a globe?
- wenc 1y agoBtw, you can plug your comment into ChatGPT and it'll give you a reasonable answer. The short answer is: distortions.