First, I have a shapefile consisting of square grids and each grid has an ID. Second, I have a shapefile consisting of different zones (with IDs).
A grid ID in the first shapefile can contain many zone IDs from the second shapefile.
I want to know what is the dominant zone ID inside a grid and record that in a table. I only want to know the dominant zone (in terms of the area) and not the rest of the zones intersecting that grid. In the end, I would want a 2-column table with all the grid IDs in the first column and the corresponding dominant zone ID (or the largest zone in terms of area) in the second column.
Here is a sample figure. By just looking at the figure, I could tell that in Grid ID 1, the dominant zone/area is Zone ID 1. In Grid ID 2, the dominant zone/area is Zone ID 2. And in Grid ID 3, the dominant zone/area is Zone ID 3. I would like to have a table with two columns, with each grid showing only the ID of the dominant area.
Answer
INPUT:
After dissolving zones use following WORKFLOW:
arcpy.Intersect_analysis("GRID #;ZONE #","D:/Scratch.gdb/intersect")
arcpy.Sort_management("intersect", "D:/Scratch.gdb/sorted","Shape_Area DESCENDING")
# DELETE MINORITIES USING GRID ID
arcpy.DeleteIdentical_management("sorted", "ID")
OUTPUT SHOWS "SORTED" AND GRID:
Transfer dominant zone ID to grid layer from "sorted", using join by attributes, if necessary.
Important update a year later: each zone must be a single, potentially multipart polygon. If this is not a case original zones layer must be dissolved by zone name.
No comments:
Post a Comment