Removing holes from Polygons generated using UnionAggregate

Jul 8, 2008 at 3:50 PM
I am working to process some ESRI data that was imported into MsSqlSpatial. The simple description is that we have certain bounaries on a map that we need to aggregate into parent areas so we can display boundaries at several levels of organizational heirarchy.

The imported data has some slight inconsistencies in it that prevent UnionAggregate from working unless I buffer the input polygons. Even doing this I am still getting some small holes in the unioned polygons where the boundaries did not line up exactly. I can remove these by increasing the buffer on the input polygons or running buffer on the output. However, using buffer with a large enough distance parameter to remove the holes leads to visible overlap of the polygon boundaries at closer zoom levels.

Is there a better way to remove small holes from these polygons while leaving large holes for features such as lakes. There is 1 to 2 orders of magnitude difference in size between the holes to discard and those to keep.

Also I am not opposed to creating a custom aggregator that can tollerance unions etc if there are any methods in NTS that could support this. My initial inspection did not find any, but I know there are people on this forum that have more expertise with these libraries than I do.

Best Regards,
Jon
Developer
Jul 8, 2008 at 4:28 PM
Perhaps this method on GeometryFactory (this is from NTS 1.7.x slightly different in v2) could help:

public IPolygon CreatePolygon(ILinearRing shell, ILinearRing[] holes)

you could do something like

IPolygon myaggregate = GetAggregate();
IPolygon processed = mygeometryFactory.CreatePolygon(myaggregate.ExteriorRing, GetLargeHoles(myaggregate.InteriorRings));

where GetLargeHoles filters out the small ones. There may well be a better way.. hth jd

Jul 8, 2008 at 7:08 PM
Take a look also at IGeometry.Apply(IGeometryComponentFilter filter) that looks what you need