jderekito

area of overlap between polygons in two different feature classes

Discussion created by jderekito on Jun 26, 2012
Latest reply on Jun 27, 2012 by dlee-esristaff
Hello ArcPy folks,


I am working on a script to get the area of overlap between polygons in two different feature classes.  I am able to loop through one polygon by polygon while looping through the other.  But, I am stuck at how to get the area of overlap.  Any suggestions would be awesome.  Here is my code:



import arcpy

arcpy.env.workspace = "C:/path/PADUS/Polys.gdb"

countiesFC = "Counties"
countyRows = arcpy.SearchCursor(countiesFC) 
countyFields = arcpy.ListFields(countiesFC)

PADUSFC = "PADUS"
PADUSRows = arcpy.SearchCursor(PADUSFC) 
PADUSFields = arcpy.ListFields(PADUSFC)

countyGeom = arcpy.Geometry()
countyGeomList = arcpy.CopyFeatures_management("Counties", countyGeom)
PADUSGeom = arcpy.Geometry()
PADUSGeomList = arcpy.CopyFeatures_management("PADUS", PADUSGeom)

countyIndex = 0
#arcpy.AddMessage(str(len(countyGeomList)))
for countyRow in countyRows:
    countyGeom = countyGeomList[countyIndex]
    #arcpy.AddMessage("county: " + countyRow.name + " - " + str(countyGeom.area))
    PADUSFC = "PADUS"
    PADUSRows = arcpy.SearchCursor(PADUSFC) 
    PADUSIndex = 0
    for PADUSRow in PADUSRows:
        PADUSGeom = PADUSGeomList[PADUSIndex]
        if PADUSGeom.overlaps(countyGeom):
            arcpy.AddMessage("PADUS: " + PADUSRow.own_type + "overlaps " + countyRow.NAME)
            #here want to find the area of overlap between the two geometry polygons
        PADUSIndex = PADUSIndex + 1
        #arcpy.Delete_management("C:/temp/test.shp")
    del PADUSFC
    del PADUSRow
    del PADUSRows
    #arcpy.AddMessage(str(countyIndex))
    countyIndex = countyIndex + 1
        





Thanks,
Derek

Outcomes