-1

My script ArcGIS 10.2 is using the searchcursor to read the mLanduse feature class to return the value in lField, but it is only returning the first value in lField to populate the sField in mSoils.

# Loop through the rows and update the blank sField values in mSoils
# with the lFields from mLanduse
     for row in cursor:
         with arcpy.da.UpdateCursor(mSoils, sField, "SoilType = ' '") as cursor2:
             for row2 in cursor2:
                 row2[0] = row[0]
                 row = cursor.next()
  • I'm already using da.SearchCursor. – Mark W Apr 30 '15 at 8:27
  • Have u tried with if row2[0] == None: – SIslam Apr 30 '15 at 8:36
  • Weird, only fills every second blank field in sField with first value of lField. – Mark W Apr 30 '15 at 8:43
  • Can u post snapshot of ur attribute tables with table filed type (e.g. String, Double etc.) – SIslam Apr 30 '15 at 9:31
2

If I understand well, the problem here is that you want to do a spatial join (based on location) but you are using a method for table join (based on a "key" field). Indeed, there does not seem to be a key field and you don't have the same number of feature, so you will not be able to get the match based on your attributes. I suggest that you start with arcpy.SpatialJoin_analysis and the match option "within", then you can update your empty fields with your update cursor. The disadvantage of the method is that it creates a new feature class, so you could also use the geometry within your cursor, but I have no time to write the script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.