Hi Xander, Please kindly Could you help me out, I am totally not understanding that how i can use the logic to take 8 days time spam raster and do calculation for multi-parameters ,
I am trying to calculate some parameters (parameters mentioned in my code ) using same time span from different band using ArcPy.
I have list of raster, raster name like
MOD09A1.MRTWEB.A2012001.005.sur_refl_b01.tif
MOD09A1.MRTWEB.A2012001.005.sur_refl_b02.tif
MOD09A1.MRTWEB.A2012001.005.sur_refl_b03.tif
MOD09A1.MRTWEB.A2012001.005.sur_refl_b04.tif
MOD09A1.MRTWEB.A2012001.005.sur_refl_b06.tif
MOD09A1.MRTWEB.A2012009.005.sur_refl_b01.tif
MOD09A1.MRTWEB.A2012009.005.sur_refl_b02.tif
MOD09A1.MRTWEB.A2012009.005.sur_refl_b03.tif
MOD09A1.MRTWEB.A2012009.005.sur_refl_b04.tif
MOD09A1.MRTWEB.A2012009.005.sur_refl_b06.tif
MOD09A1.MRTWEB.A2012017.005.sur_refl_b01.tif
MOD09A1.MRTWEB.A2012017.005.sur_refl_b02.tif
MOD09A1.MRTWEB.A2012017.005.sur_refl_b03.tif
MOD09A1.MRTWEB.A2012017.005.sur_refl_b04.tif
MOD09A1.MRTWEB.A2012017.005.sur_refl_b06.tif
In raster name different bands and 8 days interval time spam is there (e.g. A2012001, A2012009, A2012017……………A2012361)
I trying to calculate some parameters for each time spam using different band and will loop same function on all time span (time spam 8 days interval: A2012001, A2012009, A2012017……………A2012361).
For instance, whatever raster bands in 2012001 time span , will calculate different parameters , and save it 001_EVI, 001_LSWI, 001_PSCALAR, after calculation program will take 2012009 time span all bands and do same calculation and save it 002_EVI, 002_LSWI, 002_PSCALAR.
I have written some code. I think its not enough to do it. And I am not understanding how to loop 8 days interval time span to all raster band.
I have attached below, reference raster and raster name list.
def main():
import arcpy
from arcpy import env
from arcpy.sa import *
import os
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True
ws_in_mean = r'D:\NPP_GUJARAT\MODIS_DATA\MODIS_NDVI_2012\MASKED_2012C'
ws_out_EVI= r'D:\MODIS_SURFACE_RF2012\EVI'
ws_out_LSWI= r'D:\MODIS_SURFACE_RF2012\LSWI'
ws_out_pscalar = r'D:\MODIS_SURFACE_RF2012\PSCALAR'
arcpy.env.workspace = ws_in_mean
lst_ras_mean = arcpy.ListRasters()
print "lst_ras_mean", lst_ras_mean
for ras_name in lst_ras_mean:
ras_num = ras_name[:3]
ras_mean = arcpy.Raster(os.path.join(ws_in_mean, ras_name))
print "ras_mean", ras_name
ras_EVI = 2.5 * (b01 - b02) / ((b02 + (6 * b01) - (7.5 * b03) + 1)
out_name_EVI = os.path.join(ws_out_EVI, 'r{0}_EVI.TIF'.format(ras_num))
ras_EVI.save(out_name_EVI)
ras_LSWI = (b02 - b06 ) / (b02 + b06)
out_name_LSWI = os.path.join(ws_out_LSWI, 'r{0}_LSWI.TIF'.format(ras_num))
ras_LSWI.save(out_name_LSWI)
ras_pscalar = 1 + ras_LSWI / 2
out_name_pscalar = os.path.join(ws_out_pscalar, 'r{0}_PSCALAR.TIF'.format(ras_num))
ras_pscalar.save(out_name_pscalar)
if __name__ == '__main__':
main()