i have a .shp file of gridded daily rainfall data for an entire state.

How do i calculate the sum of all 365 days (each day is a field, n recorded for 450 stations) and generate a raster?

I am using ArcGIS Desktop 10.5.

  • 1
    Welcome to GIS SE! As a new user be sure to take the Tour to learn about our focussed Q&A format. I recommend not thinking about GIS SE as being some sort of online GIS tutor. For your questions to be answered here they should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that.
    – PolyGeo
    Commented Jun 2, 2018 at 7:58

1 Answer 1


Would be a simple task for Field Calculator but since you have 365 fields use the da.UpdateCursor instead and list fields using ListFields. The tricky part is to only list the 365 field you want to sum and not ObjectID field, Shape fields etc. You can do it by listing all fields but the ones starting with some string, for example 'SH' = Option 1, or by listing field starting with something, lets say all 365 field names start with 'rain' = Option 2.

1 - Start by adding the field you want to populate with sums using Add Field as type Double.

2 - Modify and execute this in the Python window with the feature class added as a layer to table of contents. You can run everything up to and including the print statement to get the field listing correct, then execute all.

import arcpy

field_to_calc = 'SumOfAll' #Change to match the name of your field to calculate
feature_layer_name = 'features123' #Change to match the name of the feature layer in table of contents

#Choose one, and modify so only the 365 fields are being listed:

#Option 1: List all fields except the ones starting with FI, SH, OBJ or field_to_calc
fields_to_sum = [f.name for f in arcpy.ListFields(feature_layer_name) if not f.name.upper().startswith(('FI','SH','OB', field_to_calc))]

#Option 2: List all fields starting with string XYZ or ABC
fields_to_sum = [f.name for f in arcpy.ListFields(feature_layer_name) if f.name.upper().startswith(('XYZ','ABC'))]

print fields_to_sum

#Calculate field_to_calc as sum of all listed fields
with arcpy.da.UpdateCursor(feature_layer_name,fields_to_sum) as cursor:
    for row in cursor:
        row[-1] = sum(filter(None,row[:-1]))

3 - Convert to raster with Feature to Raster using calculated field as value field

  • @AsraK.Khan nice, can you accept my answer with the checkbox?
    – Bera
    Commented Jun 2, 2018 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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