Intersection error issue

191
1
04-03-2024 10:54 AM
V1212
by
New Contributor II
 

Im trying to determine if 1307 or 1303 occupies more of the blue polygon. I need to do this for a series of polygons and want to automate this step this using python. 

image.png

 

 

for c_id, geometry_c in c_geometries.items():
    largest_intersection_h_id = None
    largest_intersection_area = 0

    for h_id, geometry_h in h_geometries.items():
        intersection = geometry_c.intersect(geometry_h, 4)  
        intersection_area = intersection.area

        if intersection_area > largest_intersection_area:
            largest_intersection_area = intersection_area
            largest_intersection_h_id = h_id

    if largest_intersection_h_id is not None:
        c_h_dict[c_id] = largest_intersection_h_id

for c_id, h_id in c_h_dict.items():
    print(c_id, h_id)

 

 

 I get this error message when I try this code 

error.PNG

 Thanks for the help! 

0 Kudos
1 Reply
Clubdebambos
Occasional Contributor III

Hi @V1212 

I wrote a tool over here that might help: https://learn.finaldraftmapping.com/polygon-polygon-overlap-percentage-in-arcgis-pro-with-pairwise-i...

You could use the tool, or refactor the code to suit your needs.

 

~ learn.finaldraftmapping.com
0 Kudos