0

I have to merge a set of polygons creating a new polygon.
Sometimes happens that I have small holes among polygons, so when I try to merge them I receive an error.
How can I detect this and solve?

Update with some error samples

side location conflict [ (12.235768128349596, 44.387249570104892, NaN) ]
   at NetTopologySuite.Operation.Overlay.Snap.SnapIfNeededOverlayOp.GetResultGeometry(SpatialFunction opCode)
   at NetTopologySuite.Geometries.Geometry.Union(IGeometry other)
   at NetTopologySuite.Operation.Union.CascadedPolygonUnion.UnionOptimized(IGeometry g0, IGeometry g1)
   at NetTopologySuite.Operation.Union.CascadedPolygonUnion.Union()
   at NetTopologySuite.Operation.Union.UnaryUnionOp.Union()

or

found non-noded intersection between LINESTRING(12.448591764796777 41.972860890341124, 12.448731325430401 41.972841479998927) and LINESTRING(12.449 41.973, 12.448695198462875 41.972831837041554) [ (12.448716431340822, 41.972843551495508, NaN) ]
   at NetTopologySuite.Noding.FastNodingValidator.CheckValid()
   at NetTopologySuite.Operation.Overlay.OverlayOp.ComputeOverlay(SpatialFunction opCode)
   at NetTopologySuite.Operation.Overlay.OverlayOp.Overlay(IGeometry geom0, IGeometry geom1, SpatialFunction opCode)

or

Invalid number of points in LineString (found 1 - must be 0 or >= 2)
   at NetTopologySuite.Geometries.LineString..ctor(ICoordinateSequence points, IGeometryFactory factory)
   at NetTopologySuite.Geometries.GeometryFactory.CreatePolygon(ICoordinateSequence coordinates)
Luca Morelli
  • 2,530
  • 3
  • 28
  • 45

1 Answers1

0

Most of the errors you are getting are due to invalid geometries. You can check if a geometry is valid using geometry.IsValid, or by using the NetTopologySuite.Operation.Valid.IsValidOp class. To correct these errors you can usually get away with doing a 0 offset buffer: geometry = geometry.Buffer(0).

tval
  • 412
  • 3
  • 17