-
Notifications
You must be signed in to change notification settings - Fork 293
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 in multipolygons (intersection function) #794
Comments
|
If you can output the offending geometries in WKB format, you could submit it as a bug report to GEOS. |
|
Read the documentation section starting with "when called with a missing ‘y’,", and consider calling out <- st_intersection(all, all)to avoid the behavior described there (and get pairwise intersections, which you seem to want). |
|
Thanks for the reply and your time. I have been working in this a bit and below what I find. I'll assume just for a moment that the input has 3 features as here: In this case, I create all non-empty intersections of these 3 geometries "manually" as: So that the final output is: Which should be equivalent to: However, note that unlike the "manual" program, the line below throws a TopologyException. I wonder if "st_intersection" should be throwing that TopologyException. Any answer here would be super appreciated. In additional, all non-empty intersections of the main database "all" were created using the first method ("manual"). |
|
Please try in rgeos to see whether the precision model affects this, after converting all to sp classes. Further, try |
|
With: apart from generating geometry collections (point and line intersections needing dropping as having no area) with no apparent problems. Is so one of your polygons intersects with 280 others. How precise do you need your output to be? |
|
Further, this completes: so the underlying issue may be the precision setting. suggest that care may be needed, but we are dropping line and point intersections. I needed about 15GB on a 16GB machine. There are also 7510 self-intersections, I think. |
|
Thanks @rsbivand (and @dbaston for submitting the report)!
|
|
The original file is on http://spatial.nhh.no/misc/i794/, together with a WKT version (zip-compressed, otherwise 13.7GB), and a GPKG ( and It is not clear that the assignement of the language codes from The input polygons had multiple problems, not just that they overlapped. Comments welcome: @dr-jts @edzer @dbaston |
|
I can run this, but cannot follow 100% of what you are doing. What is question? |
|
See https://lists.osgeo.org/pipermail/geos-devel/2020-October/009766.html
and subsequent. The issue 794 case is in part used in JTS and GEOS, and I
followed up checking whether OverlayNG resolved all of 794.
Roger Bivand
Falsensvei 32
5063 Bergen
tir. 20. okt. 2020, 18:25 skrev Edzer Pebesma <notifications@github.com>:
… I can run this, but cannot follow 100% of what you are doing. What is
question?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#794 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACNZ3BCD5A3NKLFAD5CTU43SLW2Y5ANCNFSM4FJZICDQ>
.
|
Note that it may be the case that the WKT version of the data has been pointwise precision truncation. This means that it won't reproduce this issue correctly for two reasons:
Testing should be done with a full-precision version of the data. |
@edzer the goal is to determine if the original My understanding is that @rsbivand reran this case using GEOS OverlayNG and still encountered TopoEx errors. If this is correct I would like to find out why that is. To do that I will need a WKB dump of the two geometries causing the error in a GEOS overlay function. (And if there are multiple errors, ideally a dump of all the cases). This might need to be done by adding some debug tracing to the rsf C code? |
|
I didn't see any strange errors running this on |
|
Do you mean that: succeeds for you with OverlayNG? For me it still fails for the snapshot of 9 October; rebuilding now with 20 October - report later: This is an error occurring at some point beyond the pairwise intersections, where intersection products are submitted to further intersection. |
|
Same error for me with geos-20201020.tar.bz2, mkdir obj && cd obj && ../configure --enable-overlayng; ad-hoc test for OverlayNG indicates that it is active: Without OverlayNG: Intersection of these three objects generate the two linestrings which then have a non-noded intersection both with and without OverlayNG. I'll put the GPKG on my server, same directory. I haven't found out how to write out WKB. |
|
And: |
|
I no longer have access to |
|
http://spatial.nhh.no/misc/i794/
Roger Bivand
Falsensvei 32
5063 Bergen
ons. 21. okt. 2020, 15:07 skrev Edzer Pebesma <notifications@github.com>:
… I no longer have access to all.rds.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#794 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACNZ3BG26MUDTBAI3VCTHP3SL3MHNANCNFSM4FJZICDQ>
.
|
|
Thanks; running CBR: result (after common-bits addition) is INVALID: Self-intersection at or near point 83.8125 50.88305600000001 (83.8125 50.883056000000010499)
<A>
MULTIPOLYGON (((68.9958649999999807 55.4176659999999970, 69.0074149999999804...GEOS 3.8.1 gives me: Error in CPL_nary_intersection(x) :
Evaluation error: TopologyException: found non-noded intersection between LINESTRING (29.6806 45.2723, 29.6797 45.2827) and LINESTRING (29.6797 45.2827, 29.6806 45.2723) at 29.680570134978936 45.272265134997795. |
|
Look for the error at the end of the overlayng output. To avoid the
garulousness, comment out
That output is coming from HeuristicOverlay.cpp:
https://github.com/libgeos/geos/blame/c4aebbbc048618e75b39f6c8d85dce8e8216cf9f/src/geom/HeuristicOverlay.cpp#L206
It shouldn't be showing up unless GEOS_DEBUG_HEURISTICOVERLAY has been
enabled, however.
from Martin's reply on geos-devel.
Roger Bivand
Falsensvei 32
5063 Bergen
ons. 21. okt. 2020, 15:14 skrev Edzer Pebesma <notifications@github.com>:
… Thanks; running st_intersection(all), OverlayNG gives me the very long
error starting with::
CBR: result (after common-bits addition) is INVALID: Self-intersection at or near point 83.8125 50.88305600000001 (83.8125 50.883056000000010499)<A>
MULTIPOLYGON (((68.9958649999999807 55.4176659999999970, 69.0074149999999804...
GEOS 3.8.1 gives me:
Error in CPL_nary_intersection(x) :
Evaluation error: TopologyException: found non-noded intersection between LINESTRING (29.6806 45.2723, 29.6797 45.2827) and LINESTRING (29.6797 45.2827, 29.6806 45.2723) at 29.680570134978936 45.272265134997795.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#794 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACNZ3BAZAUZWOEBHH2W7OALSL3NDHANCNFSM4FJZICDQ>
.
|
|
Ah, the end of the OverlayNG error message: |
|
And with s2: |
|
From GRASS: |
> which(!s2_is_valid(st_as_s2(all, check = FALSE)))
[1] 42 |
|
Update: it turned out that the errors occurring when using OverlayNG were due to a small bug in the code. This is in the process of being fixed in JTS. Once it is ported to GEOS I will update this issue, and the dataset can be retested. |
|
As the JTS fix landed, I'll be working on the GEOS port of the fix: https://trac.osgeo.org/geos/ticket/1062 |
|
GEOS port completed |
|
@rsbivand That's unfortunate. As before, I wonder if perhaps OverlayNG is not actually being used? And if so, if there is any way to add debug code to the n-ary intersection to dump out the failing geometries. |
|
Even with the latest commits by Paul Ramsey to the GEOS git repo, still: For reference @dr-jts , my sf also reports that OverlayNG is in use - the test compares sliver output order which differs for the same input between pre-OverlayNG and OverlayNG. Of course, it may be that the sf nary intersection itself is broken in edge cases, or that the GEOS port doesn't pick up all of the JTS changes. I also tried 1e10 precision, and that fails too: |
|
Seems pretty clear that sf is using OverlayNG. Puzzling why the fix hasn't worked. My ideas for investigating now are:
|
|
@dr-jts Sorry not to have responded properly. I agree that tracing code needs adding to the nary intersection function. I can't do that now, as I'd have to learn several things that I do not understand first (the Rcpp package using templates, I write ony C-style Cpp). I think @edzer is also busy. I can on the other hand report success with OverlayNG on a messy 49000 multipolygon archaeological data set, but with binary interssection - it included apparently invalid polygons which stopped it before OverlayNG, but noe succeeded. |
Good to hear. Any chance that dataset is available? |
|
Initial R workflow at head of https://github.com/rsbivand/LICD_article/blob/main/LICD-Archaeo-HLC.R, so the underlying ESRI shapefile is in https://archaeologydataservice.ac.uk/catalogue/adsdata/arch-2090-1/dissemination/zip/rawhlc.zip. The boundary used for clipping is: https://raw.githubusercontent.com/digital-land/boundary-collection/master/collection/local-authority/E07000046/index.geojson. |
|
A few (8) of the polygons in the rawhic dataset are invalid, many (or all) due to "inverted shells" - i.e. polygons which self-touch at a point, forming an enclosure which should be a hole under OGC structural rules. So that's probably why this fails using the old overlay. Happily OverlayNG is less sensitive to this issue. |
Hi,
I have a large sfc (MULTIPOLYGON) objects which throw several TopologyException errors when I try to use the intersection function on them. I have a couple of questions so, If anyone has a moment, I would really appreciate it if you could take a look at this. I've attached the files in RDS format (all). Below is some example code.
all<-readr::read_rds("all.rds")None of these lines seems to work:
sf::st_is_validreturnsTRUEfor all objects. I've tried usingmapview,lwgeom::st_make_validand modifying the precision of the calculations. Only when I set precision to 100 or lower, the "rounded coordinates" become valid geometries to execute thest_intersectionfunction. This issue is related to discussions in #600 and #603. The problem for me is that rounding the coordinates (two decimal places) does not seem appropriate for the work I'm doing. I tried several strategies including rounding (and using st_make_valid) the coordinates just for next rows (sfg):all %>% st_set_precision(100) %>% lwgeom::st_make_valid %>% sf::st_is_validHowever, the issue remains.
A subset of the data that generates one of the TopologyException errors is:
I imagine I am off-track here but It seems tricky to me that the st_intersection of these three multipolygons do not work but pairwise-intersections of these rows do not generate any error. Could you please let me know what I am missing?
Apologies if I've posted this in the wrong place. I hope I am not completely off-track. In case, feel free to delete this.
The text was updated successfully, but these errors were encountered: