I am fairly new to ArcGIS and GIS operations.
I am trying to use field calculator to summarize a range of values having different FID_XXXX. For example
I have a geo table with the following FID_XXXX with their corresponding GRIDCODE.
Now I need to populate a new field ( for e.g AREA_OVERLAP) I added after the FID columns :
I was wondering if someone can help me with a .cal expression to summarize or other operations for a batch of values tied to a certain row. I am somewhat familiar with Python but not accustomed to the ArcGIS environment.
Sure. I apologize if I have not been clear in my explanation.
The first screenshot showing the field GRIDCODE has a number of corresponding FID_XXXX. Each GRIDCODE has a row of data which holds FID_XXXX values which I need to summarize. for example in case of GRIDCODE=0 ,the new field TOTAL_AREA_OVERLAP will hold sum of all (FID_5194+FID_5203+.....)
Since there are a large number of such columns and there is no fixed range for the FID_XXXX property I need to run a loop for summing the values in all columns starting with string FID_% for each row and populate that value inside TOTAL_AREA_OVERLAP. Summing is one of the operation I need. Similar to this I may also need mean, median etc as well.
Hope this helps. Thank you.
I'm not sure how you do this in the field calculator, but here's how you can do it in Python:
>>> fc = 'points' # change to your feature layer name
... fid_fields = [i.name for i in arcpy.ListFields(fc,'FID_*')] # list of "FID_" fields
... all_fields = ['TOTAL_AREA_OVERLAP'] + fid_fields # add overlap field to beginning of list
... with arcpy.da.UpdateCursor(fc,all_fields) as cursor: # update cursor
... for row in cursor: # loop through cursor
... total = 0 # start at 0
... for i in range(len(fid_fields)): # for each FID field
... total += row[i+1] # accumulate
... row = total # store total in first position
... cursor.updateRow(row) # write row
so you have a table which is largely empty and there is no pattern to what is in there? or are you just trying to sum the values for the fields for each row. Now if the field structure had the same pattern, you could greatly simplify the calculation if there were a fixed number of field that you wanted to sum... and those pesky nulls. Also... this is a 2 second excel solution, why don't you just shove it over there, then join the result back joining to the object id field,
Yes. I am trying to find the sum of values for the fields for each row but only the fields that start with "FID_".
About using excel , it only allows 256 columns. Still I exported it to csv and fulfilled my task. But this is just one of the tables out of several and it was getting cumbersome to manage for each tables. Hence I was hoping for a more efficient way to do it in-vivo Arcgis. I saw a number of posts about python expressions that can batch process such operations and was hoping if that is possible for my task as well.