You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking for points that fall within a rectangle on my map. But when I'm zooming out enough the search rectangle can overlap the border where longitude 179.86250559999996 for example inverts and becomes -179.78593190000004 (between Asia and North America, don't know what the name is for this "border"). Having trouble understanding what goes wrong here..
Hopefully the following screenshot explains it. It shows the rectangle I'm using to search within, the longitudes invert when dragging just over the border, and in the top log I'm getting the wrong results, the bottom log is displaying correct results.
Edit: I think a better way of explaining what I'm trying to do, is searching within a rectangle that is both in the eastern and western hemisphere. Is this possible?
The text was updated successfully, but these errors were encountered:
Welcome to the joys of working with the 180 Meridian, this blog post sets out some of the issues around it.
I think what I'd be tempted to do in your case is split your rectangle into two when it crosses the 180, and then run the operation twice, and then combine the results.
Im going to close this issue and it's a not a problem with turf as such, just a challenge with working with geographic data, but hopefully that helps get you on your way.
@stenvdb I'm not sure I get your case without an actual example.
The 180 meridian issue, well illustrated in @tmcw's article, is actually related to points beyond the -180/+180 degree range; so for instance if you had points and rectangle going from 179 to 190 or from -179 to -190 degrees.
You are saying your points though switch from round -179 longitude to around +179 (which is inside the above mentioned range)? That seems weird to me. 🤔
Anyway, if @rowanwins' suggestion (useful when dealing with 180 crossing features) is not working for you, would you please add an actual case we could test?
Anyway, what version of Turf are you using? Please note that since v5.0@turf/within has been replaced by @turf/boolean-within: while the first returned the points, of a collection, within a polygon, the latter returns just true or false whether the input point is inside a polygon or not.
Note: for the records, I just tested @turf/boolean-within and it seems to deal OK with points and polygons crossing the -180/+180 degree range. 👍
I'm looking for points that fall within a rectangle on my map. But when I'm zooming out enough the search rectangle can overlap the border where longitude 179.86250559999996 for example inverts and becomes -179.78593190000004 (between Asia and North America, don't know what the name is for this "border"). Having trouble understanding what goes wrong here..
Hopefully the following screenshot explains it. It shows the rectangle I'm using to search within, the longitudes invert when dragging just over the border, and in the top log I'm getting the wrong results, the bottom log is displaying correct results.
Edit: I think a better way of explaining what I'm trying to do, is searching within a rectangle that is both in the eastern and western hemisphere. Is this possible?
The text was updated successfully, but these errors were encountered: