Efficient way to Calculate area of overlapping polygons?

10617
6
04-09-2010 02:22 PM
aaronreyna
New Contributor
Hi everyone,

Does anyone know off a way, or can point me in the direction of an efficient way to calculate the area of overlapping polygons. What I am looking to do is to compare shapefiles on an area 1:1 relationship. The closer the overlapping area is to that 1:1 relationship, the less likely that shapefile will need to be rotated. This has to be something some has done before.

Any help would be appreciated!

Warmly,

aaron
0 Kudos
6 Replies
JonathanBaarda
New Contributor
A (relatively) simple way to do this is to make a macro and run this function:
    Private Function GetArea(FeatureA As IFeature, FeatureB As IFeature) As Double

    Dim SourceArea As IArea
    Dim TargetArea As IArea
    Dim TopoOp As ITopologicalOperator3
    Dim IntersectArea As IArea
 
    Set SourceArea = FeatureA.Shape 'FeatureA and FeatureB are the polygons to be checked for overlap
    Set TargetArea = FeatureB.Shape

    Set TopoOp = TargetArea

    Set IntersectArea = TopoOp.Intersect(pSourceArea, esriGeometry2Dimension)
        
    GetArea = (IntersectArea.Area / SourceArea.Area) * 100 'returns the percentage of first polygon which overlaps second polygon
    
    Set SourceArea = Nothing
    Set TargetArea = Nothing
    Set TopoOp = Nothing
    Set IntersectArea = Nothing


You could then check GetArea against certain preset values, etc, to determine whether or not it would need to be rotated.

I've found this particular percentage of intersect code to be invaluable, it'd be nice if ESRI had included a tool to do this.
0 Kudos
JonathanBaarda
New Contributor
A (relatively) simple way to do this is to make a macro and run this function:
Private Function GetArea(FeatureA As IFeature, FeatureB As IFeature) As Double

    Dim SourceArea As IArea
    Dim TargetArea As IArea
    Dim TopoOp As ITopologicalOperator3
    Dim IntersectArea As IArea
 
    Set SourceArea = FeatureA.Shape 'FeatureA and FeatureB are the polygons to be checked for overlap
    Set TargetArea = FeatureB.Shape

    Set TopoOp = TargetArea

    Set IntersectArea = TopoOp.Intersect(pSourceArea, esriGeometry2Dimension)
        
    GetArea = (IntersectArea.Area / SourceArea.Area) * 100 'returns the percentage of first polygon which overlaps second polygon
    
    Set SourceArea = Nothing
    Set TargetArea = Nothing
    Set TopoOp = Nothing
    Set IntersectArea = Nothing

End Function


You could then check GetArea against certain preset values, etc, to determine whether or not it would need to be rotated.

I've found this particular percentage of intersect code to be invaluable, it'd be nice if ESRI had included a tool to do this.
0 Kudos
aaronreyna
New Contributor
ah!

Very nice. Thanks, it works like a charm!

Best,

aaron
0 Kudos
RayGreen
New Contributor II
Lets say your data layer has over a 1000 polygons and you would like to know for each polygon the percentage of that polygon that is overlapped, is there a way to do this?  Maybe something that adds a field into your layer with that information?
0 Kudos
DaleHoneycutt
Occasional Contributor III
Lets say your data layer has over a 1000 polygons and you would like to know for each polygon the percentage of that polygon that is overlapped, is there a way to do this?  Maybe something that adds a field into your layer with that information?


Use either the Intersect or Identity tool and overlay the polygon feature class with itself.  (No, that's not a typo -- you can overlay a feature class with itself).  Let's say that your feature class is called "Soils".  The output of the overlay operation will be a new feature class with two fields, FID_Soils and FID_Soils1.  Select all records where FID_Soils is not equal to FID_Soils1 -- these are the polygons that overlap.  Note that you'll get two records for each overlap, one where FID_Soils = 10 & FID_Soils1 = 11, and one where FID_Soils = 11 and FID_Soils1 = 10.  The part I forget how to do is to get rid of these duplicates -- if I remember correctly I created a new field that was a concatenation of the FIDs in sort order, a field that would contain "10_11" for both records, then use the Summary Statistics tool with the FIRST option.  Now you have a table of overlapping polygons. You can then join the original soils feature class on the FID fields to get the areas and such to do your calculations.  Sorry I don't have an exact methodology for you, but perhaps this will help get your started.
0 Kudos
RayGreen
New Contributor II
Thank you i will try that!
0 Kudos