Open stebogit opened 2 years ago
I think the issue is subtracting the latitude won't give you the correct degree distance.
const width = Math.abs(nw.geometry.coordinates[0] - ne.geometry.coordinates[0]); // 0.013287829229710724
const widthDistance= turf.distance(nw, ne, {units: 'degrees'}); // 0.008982708286552414
If your starting point was at [0, 0] for example instead of [-120.0, 47.0] it would work.
This sounds like it wasn't an issue in the end? Closing but please reopen if it was a problem with convertLength.
@smallsaucepan looks related to the recent #2638 and possibly the changes made in #2106? And a difference in how turf.distance
and turf.convertLength
work. If the difference is expected, the goal of this issue might just be to clarify the behavior (and maybe underlying earth model) of each, which could make it's way into the API docs.
I wouldn't mind updating the docs if someone could explain the difference.
This is working ok. The distance between two longitudes (nw.geometry.coordinates[0] - ne.geometry.coordinates[0]
) varies with latitude though. So we can't just subtract them and use that as an "angle" to feed into convertLength().
I've had in mind to add a "Units" page to the website for a while. Let's leave this open to be resolved by the addition of that page - including gotchas when using degrees and radians as units.
Working on a line grid module, copying from the
@turf/rectangle-grid
package, I stumbled upon this inconsistency. Is it possibleconvertLength
is off or am I missing something obvious here?The earth's curvature can't justify such big difference in a 1km distance.
The way the bbox's
width
is calculated above is the same logic used now (recently updated) in defining the rectangle/square grid features, but that should produce an incorrect grid result. Though I'm not sure those changes have been already published since the output of the square grid seems fine. @rowanwins any thoughts?