How to Subtract one Polygon from Another

7795
3
Jump to solution
06-26-2014 01:52 PM
TereseRowekamp
New Contributor III
I have two polygon geometries - one is a polygon from a feature and the other is created from the current view extent (which is always the larger polygon, if that matters). I want to subtract the feature polygon from the view extent polygon, creating a polygon with a donut hole in it. Is there a simple way to do this?

I'm using VB.net.

Thanks for any advice.
0 Kudos
1 Solution

Accepted Solutions
RobertMaddox
New Contributor III
As Neil said, you can cast one of your polygons to an ITopologicalOperator and call Difference passing in the other polygon. You need to make sure that the polygon you mentioned as coming from your view extent is actually a polygon and not an envelope because envelopes are not supported by the ITopologicalOperator interface. But it's a fairly trivial matter to create a polygon from an envelope, so I'm assuming you've already done it. 😉

View solution in original post

0 Kudos
3 Replies
NeilClemmons
Regular Contributor III
You can use ITopologicalOperator.Difference
0 Kudos
RobertMaddox
New Contributor III
As Neil said, you can cast one of your polygons to an ITopologicalOperator and call Difference passing in the other polygon. You need to make sure that the polygon you mentioned as coming from your view extent is actually a polygon and not an envelope because envelopes are not supported by the ITopologicalOperator interface. But it's a fairly trivial matter to create a polygon from an envelope, so I'm assuming you've already done it. 😉
0 Kudos
TereseRowekamp
New Contributor III
Thanks Neil and Robby for your help.

I marked Robby's response as the answer because it provided a little more information if someone else looks at this thread later (I had already created a polygon from the envelope, but it's probably good to note that in the answer.)
0 Kudos