Select to view content in your preferred language

A feature overlapped with another feature

1566
9
Jump to solution
06-29-2017 10:25 AM
ShaningYu
Honored Contributor

In my ArcObjects program, I need to check where a polygon feature (named f_A here) is included / overlapped with another polygon feature (named f_B hear).  Is there an ArcObjects method for the this check-up?  Thanks.  

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor
0 Kudos
9 Replies
MicahBabinski
Frequent Contributor

Hi Shaning,

This would be really easy with arcpy, but from what I can tell this article might help you out with how to use the Intersect tool with ArcObjects geoprocessing:

https://www.esri.com/news/arcuser/1207/files/gp_arcobjects.pdf 

Or, the ITopologicalOperator.Intersect method could be used to determine if there is overlap.

Good luck!

Micah

0 Kudos
KenBuja
MVP Esteemed Contributor

Here's how I determine if a polygon overlaps another polygon

pTopoOp = pFeature.Shape
Dim pInGeometry As ESRI.ArcGIS.Geometry.IGeometry5
pInGeometry = pOtherFeature.Shape
If pInGeometry.Dimension = ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry2Dimension Then 'check if the feature is a polygon
  pOverlapGeometry = pTopoOp.Intersect(pInGeometry, ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry2Dimension)
  If Not pOverlapGeometry Is Nothing And Not pOverlapGeometry.IsEmpty Then
    'you've got an overlapping polygon
  End If
End If
0 Kudos
ShaningYu
Honored Contributor

Ken:  Thanks for your code.  Could you tell me what is the data type of  pOverlapGeometry  since I need to convert your VB into c#.  Thanks.

0 Kudos
KenBuja
MVP Esteemed Contributor

It's an IGeometry5 object

0 Kudos
ShaningYu
Honored Contributor

Before I sent my last message to you, I did try but got error:

'ESRI.ArcGIS.Geometry.IGeometry5' does not contain a definition for 'Intersect' and no extension method 'Intersect' accepting a first argument of type 'ESRI.ArcGIS.Geometry.IGeometry5' could be found (are you missing a using directive or an assembly reference?) .

My code is below:

        bool feature_In_Other(IFeature f1, IFeature f2)   {
            IGeometry g = (IGeometry)f1.ShapeCopy;  // also tried   IGeometry5 g = (IGeometry5)f1.ShapeCopy;
            ESRI.ArcGIS.Geometry.IGeometry5 pInGeometry = (ESRI.ArcGIS.Geometry.IGeometry5)f2.ShapeCopy;
            if (pInGeometry.Dimension == ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry2Dimension)      {
                if (f1.ShapeCopy.GeometryType == esriGeometryType.esriGeometryPolygon)         {
                    ESRI.ArcGIS.Geometry.IGeometry5 pOverlapGeometry = g.Intersect(pInGeometry, ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry2Dimension);  // Got error on this line

                }
            }
        }

What's wrong in my code?  Thanks.

0 Kudos
KenBuja
MVP Esteemed Contributor

The Intersect method is called on the ITopologyOperator object. In my code, that's what the pTopoOp is.

Dim pTopoOp As ESRI.ArcGIS.Geometry.ITopologicalOperator

ShaningYu
Honored Contributor

Ken:  I revised the code per your feedback. The error was gone.  Thanks.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

How to Execute Spatial Queries—ArcObjects 10.4 Help for Java | ArcGIS for Desktop .  The article is for Java, but the concepts translate to .NET.

0 Kudos
ShaningYu
Honored Contributor

Thanks a lot.

0 Kudos