polygon found with search cursor, but not update cursor

المشرف العام

Administrator
طاقم الإدارة
Here's my issue. I am doing two things with arcpy:1) I search a feature class using arcpy.da.SearchCursor() and pull out a uid field and the geometry in WKB format for all polygons in the file, storing them in a ditcionary2) I open a different, but similar feature class and use arcpy.da.UpdateCursor() to update the geometries of polygons that have the same uid as above.

The problem is not all of the polygons are getting updated, even though the exact same uids exist in both feature classes. Some of them update just fine, but just under half do not.

import arcpy, timeupdated_rid_dict = {}updated_rows = 0# Grab UIDs and geometries of updated regionswith arcpy.da.SearchCursor(good_geometry_shape, field_names=['RegionID', 'SHAPE@WKB']) as cursor: for row in cursor: updated_rid_dict[row[0]] = row[1]print "{} updated regions found".format(len(updated_rid_dict)) # returns 594# Open an edit session and attempt to find all the regions in updated_rid_dictedit = arcpy.da.Editor([path to my data])edit.startEditing(False, False)edit.startOperation()with arcpy.da.UpdateCursor(bad_geometry_shape, field_names=['RegionID', 'SHAPE@WKB']) as cursor: for row in cursor: # See if the feature is in the updated_rid_dict if row[0] in updated_rid_dict: updated_rows += 1 del updated_rid_dict[row[0]]edit.stopOperation()edit.stopEditing(True)print "{} rows updated.".format(updated_rows) # Returns only 313The code above doesn't even attempt to do an update. I can literally change "UpdateCursor" to "SearchCursor" and suddenly arcpy can find all the polygons in updated_rid_dict. I change it back to "UpdateCursor" and arcpy can only find some of the regions. I'm clueless as to what could be going wrong. Any ideas?



أكثر...
 
أعلى