ThinkGeo.com    |     Documentation    |     Premium Support

Polygons "donut" hole removal

Hello,

I am trying to remove blank holes that are within a polygon. My initial thoughts were to loop through the inner rings and remove them, however, this produced undesired results. Instead of removing “donut holes” it removed other features which I did need. This makes sense but now I am back to square one and am stuck with how to remove/fill in the holes contained within a polygon. I also tried to do a convex hull to get the perimeter but was unsuccessful. I am not modifying any features from the shape file. I am only loading them into an sq lite database.

Thank you for any help!

-Mike

Id like to clarify what I mean by donut holes:

By donut holes, I am referring to space contained within a feature that is blank. It is non-clickable and not apart of the feature but is contained within the polygon.

These donut holes are what I need to fill in.

Thanks!

Hi Mike,

I think a screen shot should help us understand what’s the “donut holes”, and please provide us a WKT for it.

And you mentioned you only import that from shape file into database, does that means the “donut holes” only appear in database but in shape file it’s not exist?

Regards,

Don

Hi Don,

When I view the features from both the original files and the database, they both contain these holes. Here is 3 examples of the WKT.

WKT1.txt (60.2 KB)
WKT2.txt (11.1 KB)
WKT3.txt (34.1 KB)

Thanks for your help!

-Mike

Hi Mike,

Thanks for your data and screen capture, but the mainly question is I still hadn’t follow what’s your requirement.

Just like you mentioned, the “donut holes” is the innerRings for a polygon, if you want to fill them, you can directly loop all polygon in the multipolygon and clear its inner rings. But I guess maybe you just want to fill color but keep the border for inner polygon right? If that’s what you want, I think you can remove inner rings from polygon, create new polygon based on the removed inner rings, and add them back to the multipolygon, which can keep the border and remove the white blank.

Wish that’s helpful.

Regards,

Don

Hi Don,

I have everything working great now.

Thank you for your assistance!

Hi Mike,

I am glad to hear that works.

Any question please let us know.

Regards,

Don