Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am working on ArcGIS 10.2.1. I have a feature class containing more than 4000 records and a table having approximately 1000 records. Both feature class and table have some common fields however, with different values in them. Feature class is in ArcSDE geodatabase and table is in file geodatabase. We want to update feature class's fields with the values in table.

There are multiple fields (100 above). I was thinking of joining these two and then use field calculator but as records in feature class are more than the table and there are multiple fields which I want to update.

Is there any python script or tool I can use to update the feature class values from the table?

share|improve this question
1  
Welcome to GIS.SE. you should indicate what software you are using to help people provide an appropriate answer. Assuming you are using ArcGIS, you might also consider using Modelbuilder for this task, in addition to a script or tool –  TDavis Jul 24 at 16:35
1  
You say you have common fields, but with different values. This rules out a join. How do you select which record in the feature class should be updated with the data from the table? –  recurvata Jul 24 at 16:37
1  
You say the table and the FeatureClass have a common field structure. I assume they both have an ID field which links them? For example row ID 101 in the FeatureClass has a 101 in the table and its the values in this table you want to take and overwrite in the FeatureClass? –  Hornbydd Jul 24 at 16:38

1 Answer 1

How about something like this:

import arcpy
mainTbl = r"C:\test.gdb\main"
lutTbl = r"C:\test.gdb\lut"
#Note the order of the fields in the search cursor has to coincide with field order in the update cursor
#Also assumes the matching fields are of compatibale types (exanple: can't insert string into integer)
lutDict = {r[0]:[i for i in r[1:]] for r in arcpy.da.SearchCursor(lutTbl, ["JOINFIELD","FIELD_A","FIELD_B","FIELD_C"])}
updateRows = arcpy.da.UpdateCursor(mainTbl, ["JOINFIELD","FIELD_A","FIELD_B","FIELD_C"])
for updateRow in updateRows:
    joinFieldVal = updateRow[0] 
    updateRow[1:] = lutDict[joinFieldVal]
    updateRows.updateRow(updateRow)
del updateRow, updateRows, lutDict
share|improve this answer
    
thanks for the reply!!. I will try this at my end. –  Anjali Jul 24 at 21:22
    
Note slightly more memory efficient (but also a bit slower) if you force a tuple: lutDict = {r[0]:tuple(i for i in r[1:]) for r in arcpy.da.SearchCursor(lutTbl, ["JOINFIELD","FIELD_A","FIELD_B","FIELD_C"])} –  csny490 Jul 24 at 21:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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