[GIS] the problem with the polygon? Getting a *”found non-noded intersection”* exception error

nettopologysuite

I am working on a GIS program in which I needed to find the difference between the two polygons so, I decided to used NetTopologySuite (NTS) to find the difference.

It seems to be working on some of the polygons and on some it is not working at all, it gives an "found non-noded intersection". So, I drilled down more and found that it is not the difference function but it was the polygon which was screwing everything up. Here is the polygon which was giving exception "found non-noded intersection":

POLYGON ((51020.548917151937 215, 51025.909273225909 215,
51011.728078042863 215, 51009.760352395453 215, 51000.668102852258 215, 50988.318928099558 215, 50979.498088990484 215, 50974.5448485677
215, 50969.59160814491 215, 50963.0777577259 215, 50943.129090817689
215, 50940.482839084973 215, 50940.482839084973 215,
50885.820734580833 215, 50862.136328915352 215, 50840.782769521713 215, 50836.271454156857 215, 50829.654858288406 215,
50821.008170505767 215, 50814.767517584383 215, 50803.113286225176 215, 50779.203314791455 215, 50763.940031140366 215,
50751.308348118779 215, 50723.714135803755 215, 50702.886896536016 215, 50677.02202177752 215, 50659.72864621225 215, 50653.1120503438
215, 50649.954129588405 215, 50646.495454475349 215,
50620.630579716853 215, 50588.073920500494 215, 50574.840728763593 215, 50574.840728763593 215, 50554.915752568821 215,
50548.223968110957 215, 50481.230934942883 215, 50474.614339074433 215, 50425.365813008117 215, 50420.177800338533 215,
50405.440836813345 215, 50400.252824143761 215, 50348.523074626777 215, 50333.259790975688 215, 50317.9965073246 215, 50225.965673881583
215, 50209.424184210453 215, 50191.228545572209 215,
50174.762244490492 215, 50126.1904157289 215, 50126.1904157289 -100, 51020.548917151937 -100, 51020.548917151937 215, 51020.548917151937 215))

and following is the exception which I was getting after creating the polygon in NTS:

found non-noded intersection between LINESTRING(51020.5489171519 215,
51025.9092732259 215) and LINESTRING(51025.9092732259 215, 51011.7280780429 215) [ (51020.5489171519, 215, 53973.4510575744) ]

What is the problem with the polygon?

Best Answer

Your error says:

found non-noded intersection between LINESTRING(51020.5489171519 215, 51025.9092732259 215) and LINESTRING(51025.9092732259 215, 51011.7280780429 215) [ (51020.5489171519, 215, 53973.4510575744) ]

Had trouble visualizing it so I loaded your WKT to the Geometry Visualizer and found this on the upper right corner:

enter image description here

That's what's making your geometry invalid. You'll have to fix that corner if you want the error to go away. I think it's best to check your polygons for validity before you put them through any operations. Would save you a lot of headaches.

Related Question