-
Notifications
You must be signed in to change notification settings - Fork 944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
degreesToDistance
different for Latitude and Longitude
#684
Comments
Web Mercator
The Leaflet map you have in the background is using Web Mercator projection which is an equidistance projection (distances are equal only in meters NOT degrees). Because of the earth's curvature, calculating the distance of 1 degree North does NOT equal 1 degree West. The map you are showing is accurate to represent those points the way they are. If you decided to visualize the same thing using a Geodetic map projection (WGS84) then those two points will "look" like they have an equal distance. Square
I don't think using |
Going to close this issue, however feel free to continue the discussion if you have more questions/comments. |
@DenisCarriere does that mean the output of What about the (failing) tests I added (those function did not have any tests BTW)? Are they maybe incorrect? |
Those tests are not really failing, it's just a precision issue, converting degrees to meters and meters back to degrees will have some very minor different decimals (< 10cm). Also the distance measurement of The higher/lower in latitude, the greater the distortion (curvature of the earth). SolutionYou might want to consider using Tests Failing709eff0#diff-53d607b71ed5b9cdaec1b6400fb83a8eR327 const dx = distance(point([-120, 47]), point([-120.5, 47]));
const dy = distance(point([-120, 47]), point([-120, 47.5]));
t.equal(distanceToDegrees(dx), .5, 'degrees conversion fails');
//=0.34099
t.equal(distanceToDegrees(dy), .5, 'degrees conversion fails');
//=0.5
Test Passing with latitude 0
|
@DenisCarriere I'm still not sure about the result of the function. Any thoughts? |
@stebogit Totally agree that including a latitude as parameter is a must to calculate the distance properly (distances that span large areas will have distortions). 👍 Including a new |
I don't remember if I've had this conversation with someone before, but why aren't we using @mourner Any objections to this? |
@DenisCarriere 👍 |
Yep, we can reopen this issue and tag it as a bug. |
@DenisCarriere I believe the issue here is just the name of the function(s), and also some confusion on my side. What causes confusion (at least to me, sorry) is the name of the functions and the fact that in the additional test I added I was actually measuring a distance (in fact using Therefore the values returned by the functions under discussion are correct, but I would strongly suggest (in the next major release) to change the names for example to What do you think? While I was thinking about this whole thing and trying to understand the issue I modified cc: @mourner @rowanwins |
@DenisCarriere any thoughts on the conversion to |
@stebogit I'm 👍 with the method renaming, pretty sure these methods are only used internally. We can include these changes in v5.0 and update the |
Hey guys i tried to follow this conversation but geospatial discussion goes over my head :/. If I had a lat/lng pair and wanted to change the position by 1 mile in any direction, which function should i use? |
@guanzo if you have just a point you can use var pt = turf.point([lng, lat]); // note the order
var destinationPoint = turf.destination(pt, 1, yourDirectionAngle, 'miles'); |
|
@stebogit can you tellme how you create a line with arrow like that ? |
@Gefyaqiilah I just edited a screenshot with Preview on Mac, nothing done with turf |
Looking at
@turf/helpers
distanceToRadians
anddistanceToDegrees
methods I noticed that if you move a point E-W or N-S of the same amount of degrees and calculate the distance between the original point and the moved point, you actually get two different distances.Is that for some reason correct?
If so, why?
Then, how could you create for example a square from a
point' that actually looks like a square? Using
@turf/bearing`, due to #681, at 90˚ the end points are not at the same latitude, while varying the coordinates you don't get a square:I added also some test on
@turf/helpers
to highlight the issue.The text was updated successfully, but these errors were encountered: