# Create new field mappings and addd both feature classes fieldmappings = arcpy.FieldMappings() fieldmappings.addTable(Input_Polygons) fieldmappings.addTable(Counties) # create output feature for spatial join outstewardshipcounties = os.path.join(arcpy.env.scratchGDB, "StewardshipCounties") #run spatial joint tool arcpy.SpatialJoin_analysis(Input_Polygons, Counties, outstewardshipcounties , "#", "#", fieldmappings, "HAVE_THEIR_CENTER_IN") #create dictionary path_dict = { } rows = arcpy.SearchCursor(outstewardshipcounties) for row in rows: keyrow = row.getValue("ObjectID") valrow = row.getValue("FIPS_TXT") path_dict[keyrow] = valrow urows = arcpy.UpdateCursor(Input_Polygons) for urow in urows: upkey = urow.getValue("ObjectID") if upkey in path_dict: urow.setValue("County", path_dict[upkey]) urows.updateRow(urow) del row, rows, urow, urows
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.