-
Notifications
You must be signed in to change notification settings - Fork 366
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
TopologyException on union of valid geometries #1170
Comments
This is an issue in JTS as well. It's a robustness issue in the overlay code. No fix at the moment. It does work using Snap Rounding, with a fairly large scale factor (10^7). Not sure if that's available in Shapely. |
I don't immediately find anything regarding snaprounding in the shapely API, nor in the GEOS C API, so I suppose not. I have 4 more cases that also lead to "TopologyException: Ring edge missing at...", and 3 that give a "TopologyException: found non-noded intersection between ..." error. Is it useful to find the exact culprits for those cases as well (no problem to do so, it takes about 5 to 10 minutes per case to seperate them from the 3 million input polygons in total) or is it very likely that they all lead back to the same issue? |
It looks like the Shapely overlay functions accept a |
It would be interesting to see some other failure cases. They may have different causes, which may (or may not) be easier to fix. |
OK, I further automated the discovery of the extra cases... each .csv contains some WKTs that when unioned trigger an error. error_6.csv |
Ah, oops, ok... grid_size is synonymous for snap-rounding... I should have known, sounds logical (blushing). |
Thanks. I confirm I see the errors as well. I can't offer any fast resolution for this, unfortunately. But you might try either using snap-rounding (via specifying a grid size in Shapely), or doing some amount of precision reduction on the coordinate values (which will likely move coordinates enough to avoid these problems. Since you're using Shapely, can you catch the error and use snap-rounding only on the cases which cause the error? (It may be that this strategy can be built into the Unary Union code itself - but I haven't figured out yet how to do this in a way that won't reduce performance across the board.) |
I was actually allready applying Because of your advice that using snap-rounding/gridsize in the Thanks a lot already! |
Nice! Glad that helped. I'll keep thinking about a more fundamental fix that will solve this problem for all users of JTS and GEOS. |
This is similar to #942. And like that situation, this can't be solved by simple area or envelope check heuristics (since the results lie within the inputs). |
Doing a union of a combination of 4 specific geometries leads to a TopologyException: Ring edge missing at ... .
They aren't the prettiest geometries, and they overlap... but they are all valid, so...
Script to reproduce (using shapely 2.0.6 with geos 3.13)
The text was updated successfully, but these errors were encountered: