AnsweredAssumed Answered

Return the value of field in a selected feature

Question asked by jborgion Champion on Jan 31, 2018
Latest reply on Jan 31, 2018 by Dan_Patterson

I have a set of points that I need to cycle through and for each point, spatially select the polygon in which that particular point falls.  I then need to compare a couple values in the point to the value of a field in the selected polygon.

 

Stepping through the points is easily accomplished with an arcpy.da.SearchCursor; I can make the spatial selection easily too.  But how do I get the value of a particular field in the selected polygon? (It's my understanding that nesting another search cursor after Line 4 is bad practice.)

 

fields = ["StreetDir", "HouseDir"]
with arcpy.da.SearchCursor("points",fields) as cursor:
   for row in cursor:
      arcpy.SelectLayerByLocation_management("quads","CONTAINS","points")

StreetDir and HouseDir have values of N,S, E or W.

 

The quads feature layer has a field called DirValues in the form of a tuple: ("S", "W") or ("S", "E") etc.  I need to see if row[0] and row[1] are in the selected tuple.

 

Is there a way to tease values out with describe?  Or is there some "get-selected-feature-field-value" method I haven't found with google?

Outcomes