AnsweredAssumed Answered

Matching monthly rasters for different variables

Question asked by tonalca6864 on Nov 29, 2018
Latest reply on Nov 29, 2018 by Dan_Patterson

Hi,

I have a set of raster layers that I need to match monthly and perform a simple operation:

The operation being, for example:

(Aale_Vector_UpW_apr_per + Aale_Vel_UpW_apr_per + Aale_Vvel_UpW_apr_per) / 3

 

Same for all months.

 

I've tried the code below with no success (no outputs are produced). It doesn't generate an error either. Obviously, I'm missing something...

 

# SUM THE MONTHLY PERCENTAGE VALUES FOR EACH PARAMETER AND DIVIDE BY 3 TO KEEP IT AS VALUE BETWEEN 0-100

env.workspace = r"D:\000_TEST_MAGNITUDE_summary\MAX_VAL_calculation\TEST_IN.gdb"

OUTworkspace = r"D:\000_TEST_MAGNITUDE_summary\MAX_VAL_calculation\TEST_OUT.gdb"


# List of rasters

vvelrast = arcpy.ListRasters("*Vvel*")

velrast = arcpy.ListRasters("*_Vel*")

vecrast = arcpy.ListRasters("*Vector*")


# Pair the three monthly parameters

for vvel in vvelrast:

    for vel in velrast:

        for vec in vecrast:

            if vvel[:7] == vel[:7] == vec[:7]:


                outRas = (Raster(vvel) + Raster(vel) + Raster(vec)) / 3

                outRas.save(OUTworkspace + "\\" + vel[:4] + "_Upwelling_mag_" + vel[13:16])


print "DONE"

Outcomes