AnsweredAssumed Answered

File saving and naming

Question asked by lpalao on Aug 28, 2014
Latest reply on Sep 11, 2014 by jmward

Hi Python Users,

 

I want to automate my filenaming in my python script. This is what I am doing.

 

I am calculating a bunch of rasters using the implementation of raster calculator / map algebra in python. I want to save my output in this way:

 

PET_001.tif

.

.

.

.

PET_037.tif

 

here is the script that I am running:

 

clim = r'path\to\rasters'

arcpy.env.workspace = clim

clim_rasters = arcpy.ListRasters()

 

for raster in clim_rasters:

    tmax_ras = arcpy.ListRasters("Tmax*")

    tmin_ras = arcpy.ListRasters("Tmin*")

    ra_ras = arcpy.ListRasters("RA*")

   

    PET5 = 0.0023 * Raster(ra_ras) * ((Raster(tmax_ras) + Raster(tmin_ras) / 2.00) + 17.8) * ((Raster(tmax_ras) + Raster(tmin_ras))**0.5)

 

I need to save my output in such a way described above. Help please.

 

Thanks,

-Leo

Outcomes