-
Notifications
You must be signed in to change notification settings - Fork 950
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
found non-noded intersection between LINESTRING #297
Comments
Hi @ajmas Turf.intersect is designed to work with two polygons so I'm a bit confused why you're calling turf.intersect(poly, point1) ... It's a bit hard to work out what else might be going wrong with your code from your description, you might be able to use something like Turfjs.party or jsfiddle to provide a better idea of what you've got so far. Thanks, |
I'm experiencing the same error with 2 polygons. Fairly simple ones at that... It appears to happen when coordinates in a polygon are so close together so as to appear identical. In the above fiddle, it's the second to last and last one (of the more complex polygon (f1)). Maybe I need to simplify first or something... |
My use case was to taking an existing geojson data source, which provides country outlines. I then wanted to find in which polygon a given coordinate existed, so I could derive which country was associated with the coordinate. Except for where the error happens, get intersection of point and polygon does work. BTW used the turf.interesect() function based on recommendations elsewhere on the web, such as here: |
For my specific case, switching to turf.inside() resolved the issue. I decided to put together a test case using purely polygons and I still see the issue. Should Turf be able to handle the issue in the geojson (I see Antartica has a line crossing issue)? Have attached test-case, showing polygon issue with turf.intersect() |
Hi @sainsb , i've taken a look at your polys and indeed it's to do with that second last point which is ridiculously close to the last point (eg less than 1mm). Turf intersect uses JSTS under the hood which is based on JTS which where the geometry validation is coming from.If you run a topology check in QGIS as well you get error (see the topology check on that poly from QGIS in this image). Perhaps you could reduce the complexity of your polygons by using something like turf-simplify (a bit annoying I know)? Hi @ajmas the Antarctica poly is indeed also causing issues, if you remove that poly from the dataset then no issues are thrown. |
This is happening to me but for a different case. The cause is on the I first noticed the error was being thrown right when the first hexagon of the grid did:
I knew the hex wasn't supposed to intersect the polygon, and thought the error derived from there, or maybe because the intersection was too small, promptly making a
Am I using UPDATE: the problem was only happening with some strange polygons. However I wonder if the error could be more explicit, or if the intersect could even support these kind of polygons. Heres a detail of one the strange shapes: |
The non-noded intersection error is thrown when self-intersecting polygons are detected. These polygons are invalid, since the interiors & exteriors of the hulls are ambiguous. |
@morganherlocker Is there anyway to test if a given polygon is a self-intersecting polygon beforehand? That way, I could test it and try to create an approximate convex polygon before the intersection. |
@fplgusmao turf-kinks finds all self intersections in a Polygon. |
@morganherlocker Cool! Thank you very much |
I also experienced this "found non-noded intersection between LINESTRING..." error with two polygons that passed ST_IsValid() in postGIS. I got around it by doing a turf.buffer on the offendiong polygons before calling turf.intersect, but I am not sure what the performance implications are of this method |
This can also result from passing in MultiPolygon geometry (with no self-intersections) |
I'm seeing this relatively often. The cause for me is that the underlying library, JSTS, loses some coordinate accuracy when converting to and back from JSTS's own format. After this apparently two "identical" coordinates end up being slightly different:
I got the error from dissolve. My workaround is to specify a different PrecisionModel from the default one used. I had to fork turf-dissolve and turf-union for this (note the different API for union).
|
I had a similar issue and found that using turf.truncate() on the geometries solved the problem. This might be useful for some people if their geometries currently have an unnecessary level of precision. |
👍 Thanks for the update @njriordan , agreed that using |
I'm getting this I wrote up a test case demonstrating the error, only to find that it is already fixed on #1225. Looking forward to that getting merged in! |
Hi, I'm also experiencing the same error (turf 5.1.6), with 2 simple polygons. https://stackblitz.com/edit/turf-non-noded-intersection-error |
|
@fredmilhau I resolved it by switching the method I used. See: #297 (comment) |
use turf.simplify.see: #463 |
I ran into the following error, when calling
turf.intersect(poly, point1)
A bit of background:
I am using a combination of turf and turf-multipolygon, with the geojson outline at http://openlayers.org/en/v3.8.2/examples/data/geojson/countries.geojson
My code looks something as follows:
The issue happens with the entry for Antartica (ATA). Should the intersect function be dealing with situation or is there a function that would 'correct' the data for this situation?
BTW I did modify turf-multipolygon for use in browser based JS:
The text was updated successfully, but these errors were encountered: