[GIS] Select polygons contained inside a polygon and assign ID

arcgis-10.0arcmappython

I have a polygon feature class Base_FC, where each poly has a unique alphanumeric ID. My second polygon feature class Type_FC has the details for the various polygons which would fall inside Base_FC when intersected. These polys have unique alphanumeric IDs as well.

For display purposes, I would like to assign each Type_FC poly that falls within a Base_FC poly a number, along with its neighbouring polys. For example:

  • Base_FC polygon B1 contains three Type_FC polys T5, T8 and T11.
  • Base_FC polygon B2 contains four Type_FC polys T20, T21, T25 and T30.

The numbers should ideally be assigned spatially from left to right, so if B1 has the polys going from left to right as T8, T5 and T11, they would be labelled 1, 2 and 3 respectively. I realise that there are a number of ways to do this – the method I was thinking of was to create a model which iterates through each Base_FC feature, selects by location all the Type_FC features it contains, then use the Python field calculator to number them – but I'd like to know of other methods, or if there is a tool out there which can do this.

I'm also not sure how to handle the issue of numbering them so that visually it looks good. Maybe using the coordinates of the centroids to ensure numbering goes from left to right?

Best Answer

Had a quick think about your idea, this is is how I would approach it in modelbuilder:

  • Add an X field to your Type_FC
  • Populate X field with the centroid's X coordinate.
  • Use spatial join tool to pass the ID of the Base_FC polygons to your Type_FC polygons
  • Have an iterator cycle through the Base_FC ID's in your Type_FC polygons
  • For each ID create a new FeatureLayer setting the where clause to ID
  • Sort resulting featurelayer based upon X field
  • Get a count on the number of rows, lets call this "i"
  • Run a calculate to add numbers 1 to "i"
Related Question