<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Extracting List of Rasters By name in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1261775#M66939</link>
    <description>&lt;P&gt;Dear Sir,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am not getting any error message in this code. This is just the previous code showing what I have done till now. Please find below the formatted code. I have mentioned each step in the code, and now I want to extract Daytime Values for the Months Jan to March. The filenames in my folder are in the format of "A2021001 ..... A2021002 ...... " and so on. I would appreciate any help in this issue. Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os
##Extract Daytime Temp from Terra Folder
arcpy.env.workspace = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra/'
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/')
rootPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra/'
outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/'

hdfList = arcpy.ListRasters()

for filename in hdfList:
arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "0" )

##Extract Nightime Rasters from Terra
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/')
outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/'

for filename in hdfList:
arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "4" )

##Extract Daytime Temp from Aqua Folder

arcpy.env.workspace = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua/'
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/')
rootPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua/'
outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/'

hdfList = arcpy.ListRasters()

for filename in hdfList:
arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "0" )

##Extract Nightime Rasters from Aqua
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/')
outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/'

for filename in hdfList:
arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "4" )


##Create Mean for Day and Nighttime temps for Terra

arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/'
Terra_D = arcpy.ListRasters("*", "TIF")
arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/'
Terra_N = arcpy.ListRasters("*", "TIF")
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_mean/')

from arcpy.sa import *
for (i,j) in zip(Terra_D,Terra_N):
outCellStats =CellStatistics([f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/{i}',f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/{j}'], "MEAN", "NODATA")
outCellStats.save(f"C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_mean/{i}")


##Create Mean for Day and Nighttime temps for AQUA

arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/'
Aqua_D = arcpy.ListRasters("*", "TIF")
arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/'
Aqua_N = arcpy.ListRasters("*", "TIF")
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_mean/')

from arcpy.sa import *
for (i,j) in zip(Aqua_D, Aqua_N):
outCellStats =CellStatistics([f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/{i}',f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/{j}'], "MEAN", "NODATA")
outCellStats.save(f"C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_mean/{i}")

##Create Mean for Daily Land Surface Temperature Of all four Rasters

arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/'
Terra_D = arcpy.ListRasters("*", "TIF")
arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/'
Terra_N = arcpy.ListRasters("*", "TIF")

arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/'
Aqua_D = arcpy.ListRasters("*", "TIF")
arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/'
Aqua_N = arcpy.ListRasters("*", "TIF")

os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/')


from arcpy.sa import *
for (i,j,k,l) in zip(Terra_D,Terra_N,Aqua_D, Aqua_N):
outCellStats =CellStatistics([f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/{i}',f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/{j}', f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/{j}', f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/{k}' ], "MEAN", "NODATA")
outCellStats.save(f"C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/{i}")

#Apply Scale Factor

arcpy.env.workspace = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/'

rootPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/'

os.mkdir( 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Mean_K/')


outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Mean_K/'

rasterList = arcpy.ListRasters("*", "TIF")

for filename in rasterList:
output_raster = arcpy.sa.Raster(filename) * 0.02
output_raster.save(outputPath + filename)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 25 Feb 2023 16:19:25 GMT</pubDate>
    <dc:creator>AliTurabHani</dc:creator>
    <dc:date>2023-02-25T16:19:25Z</dc:date>
    <item>
      <title>Extracting List of Rasters By name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1261760#M66937</link>
      <description>&lt;P&gt;Hi everyone. I am using Spyder and I have downloaded MODIS data from Earth Explorer and separated the daytime rasters using ListRasters(). Now I want to separate data from the different seasons and create a mean for 3 months, and for that I will have to use the image numbers( for e,g from 001 to 089 for Jan to March). I am not able to do so using ListRasters(), and can not find a solution online. I would appreciate any help in this matter. Please find below my code for reference:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;import arcpy&lt;BR /&gt;import os&lt;BR /&gt;##Extract Daytime Temp from Terra Folder&lt;BR /&gt;arcpy.env.workspace = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra/'&lt;BR /&gt;os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/')&lt;BR /&gt;rootPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra/'&lt;BR /&gt;outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/'&lt;/P&gt;&lt;P&gt;hdfList = arcpy.ListRasters()&lt;/P&gt;&lt;P&gt;for filename in hdfList:&lt;BR /&gt;arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "0" )&lt;/P&gt;&lt;P&gt;##Extract Nightime Rasters from Terra&lt;BR /&gt;os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/')&lt;BR /&gt;outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/'&lt;/P&gt;&lt;P&gt;for filename in hdfList:&lt;BR /&gt;arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "4" )&lt;/P&gt;&lt;P&gt;##Extract Daytime Temp from Aqua Folder&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua/'&lt;BR /&gt;os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/')&lt;BR /&gt;rootPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua/'&lt;BR /&gt;outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/'&lt;/P&gt;&lt;P&gt;hdfList = arcpy.ListRasters()&lt;/P&gt;&lt;P&gt;for filename in hdfList:&lt;BR /&gt;arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "0" )&lt;/P&gt;&lt;P&gt;##Extract Nightime Rasters from Aqua&lt;BR /&gt;os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/')&lt;BR /&gt;outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/'&lt;/P&gt;&lt;P&gt;for filename in hdfList:&lt;BR /&gt;arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "4" )&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;##Create Mean for Day and Nighttime temps for Terra&lt;/P&gt;&lt;P&gt;arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/'&lt;BR /&gt;Terra_D = arcpy.ListRasters("*", "TIF")&lt;BR /&gt;arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/'&lt;BR /&gt;Terra_N = arcpy.ListRasters("*", "TIF")&lt;BR /&gt;os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_mean/')&lt;/P&gt;&lt;P&gt;from arcpy.sa import *&lt;BR /&gt;for (i,j) in zip(Terra_D,Terra_N):&lt;BR /&gt;outCellStats =CellStatistics([f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/{i}',f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/{j}'], "MEAN", "NODATA")&lt;BR /&gt;outCellStats.save(f"C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_mean/{i}")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;##Create Mean for Day and Nighttime temps for AQUA&lt;/P&gt;&lt;P&gt;arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/'&lt;BR /&gt;Aqua_D = arcpy.ListRasters("*", "TIF")&lt;BR /&gt;arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/'&lt;BR /&gt;Aqua_N = arcpy.ListRasters("*", "TIF")&lt;BR /&gt;os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_mean/')&lt;/P&gt;&lt;P&gt;from arcpy.sa import *&lt;BR /&gt;for (i,j) in zip(Aqua_D, Aqua_N):&lt;BR /&gt;outCellStats =CellStatistics([f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/{i}',f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/{j}'], "MEAN", "NODATA")&lt;BR /&gt;outCellStats.save(f"C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_mean/{i}")&lt;BR /&gt;&lt;BR /&gt;##Create Mean for Daily Land Surface Temperature Of all four Rasters&lt;/P&gt;&lt;P&gt;arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/'&lt;BR /&gt;Terra_D = arcpy.ListRasters("*", "TIF")&lt;BR /&gt;arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/'&lt;BR /&gt;Terra_N = arcpy.ListRasters("*", "TIF")&lt;/P&gt;&lt;P&gt;arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/'&lt;BR /&gt;Aqua_D = arcpy.ListRasters("*", "TIF")&lt;BR /&gt;arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/'&lt;BR /&gt;Aqua_N = arcpy.ListRasters("*", "TIF")&lt;/P&gt;&lt;P&gt;os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/')&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;from arcpy.sa import *&lt;BR /&gt;for (i,j,k,l) in zip(Terra_D,Terra_N,Aqua_D, Aqua_N):&lt;BR /&gt;outCellStats =CellStatistics([f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/{i}',f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/{j}', f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/{j}', f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/{k}' ], "MEAN", "NODATA")&lt;BR /&gt;outCellStats.save(f"C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/{i}")&lt;BR /&gt;&lt;BR /&gt;#Apply Scale Factor&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/'&lt;/P&gt;&lt;P&gt;rootPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/'&lt;/P&gt;&lt;P&gt;os.mkdir( 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Mean_K/')&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Mean_K/'&lt;/P&gt;&lt;P&gt;rasterList = arcpy.ListRasters("*", "TIF")&lt;/P&gt;&lt;P&gt;for filename in rasterList:&lt;BR /&gt;output_raster = arcpy.sa.Raster(filename) * 0.02&lt;BR /&gt;output_raster.save(outputPath + filename)&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2023 13:32:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1261760#M66937</guid>
      <dc:creator>AliTurabHani</dc:creator>
      <dc:date>2023-02-25T13:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting List of Rasters By name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1261766#M66938</link>
      <description>&lt;P&gt;Please format your code and provide error messages&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2023 14:18:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1261766#M66938</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-02-25T14:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting List of Rasters By name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1261775#M66939</link>
      <description>&lt;P&gt;Dear Sir,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am not getting any error message in this code. This is just the previous code showing what I have done till now. Please find below the formatted code. I have mentioned each step in the code, and now I want to extract Daytime Values for the Months Jan to March. The filenames in my folder are in the format of "A2021001 ..... A2021002 ...... " and so on. I would appreciate any help in this issue. Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os
##Extract Daytime Temp from Terra Folder
arcpy.env.workspace = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra/'
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/')
rootPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra/'
outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/'

hdfList = arcpy.ListRasters()

for filename in hdfList:
arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "0" )

##Extract Nightime Rasters from Terra
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/')
outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/'

for filename in hdfList:
arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "4" )

##Extract Daytime Temp from Aqua Folder

arcpy.env.workspace = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua/'
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/')
rootPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua/'
outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/'

hdfList = arcpy.ListRasters()

for filename in hdfList:
arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "0" )

##Extract Nightime Rasters from Aqua
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/')
outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/'

for filename in hdfList:
arcpy.ExtractSubDataset_management(in_raster= rootPath + filename, out_raster= outputPath + filename[8:-29] + ".tif", subdataset_index= "4" )


##Create Mean for Day and Nighttime temps for Terra

arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/'
Terra_D = arcpy.ListRasters("*", "TIF")
arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/'
Terra_N = arcpy.ListRasters("*", "TIF")
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_mean/')

from arcpy.sa import *
for (i,j) in zip(Terra_D,Terra_N):
outCellStats =CellStatistics([f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/{i}',f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/{j}'], "MEAN", "NODATA")
outCellStats.save(f"C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_mean/{i}")


##Create Mean for Day and Nighttime temps for AQUA

arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/'
Aqua_D = arcpy.ListRasters("*", "TIF")
arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/'
Aqua_N = arcpy.ListRasters("*", "TIF")
os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_mean/')

from arcpy.sa import *
for (i,j) in zip(Aqua_D, Aqua_N):
outCellStats =CellStatistics([f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/{i}',f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/{j}'], "MEAN", "NODATA")
outCellStats.save(f"C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_mean/{i}")

##Create Mean for Daily Land Surface Temperature Of all four Rasters

arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/'
Terra_D = arcpy.ListRasters("*", "TIF")
arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/'
Terra_N = arcpy.ListRasters("*", "TIF")

arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/'
Aqua_D = arcpy.ListRasters("*", "TIF")
arcpy.env.workspace ='C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/'
Aqua_N = arcpy.ListRasters("*", "TIF")

os.mkdir('C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/')


from arcpy.sa import *
for (i,j,k,l) in zip(Terra_D,Terra_N,Aqua_D, Aqua_N):
outCellStats =CellStatistics([f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_D/{i}',f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Terra_N/{j}', f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_D/{j}', f'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Aqua_N/{k}' ], "MEAN", "NODATA")
outCellStats.save(f"C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/{i}")

#Apply Scale Factor

arcpy.env.workspace = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/'

rootPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Daily_Mean/'

os.mkdir( 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Mean_K/')


outputPath = 'C:/Users/DELL/OneDrive/Desktop/ABD1/Map_Algebra/Ass1/DATA/Mean_K/'

rasterList = arcpy.ListRasters("*", "TIF")

for filename in rasterList:
output_raster = arcpy.sa.Raster(filename) * 0.02
output_raster.save(outputPath + filename)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2023 16:19:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1261775#M66939</guid>
      <dc:creator>AliTurabHani</dc:creator>
      <dc:date>2023-02-25T16:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting List of Rasters By name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1261790#M66941</link>
      <description>&lt;P&gt;you sure about your filepaths? linux or windows?&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2023 18:06:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1261790#M66941</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2023-02-25T18:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting List of Rasters By name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1261813#M66944</link>
      <description>&lt;P&gt;Hi David,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes my filepaths are correct, and I am working on windows. This code is working, and I am now trying to get the mean for the daytime rasters for the first 3 months of the year. The names of the files in the Terra_D folder are in the format "A2021001, A2021009" and so forth. I am trying to apply ListRasters() for&amp;nbsp; raster 001 to raster 089 only and get the mean and apply other statistics. Any help in this regard would be appreciated. Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2023 23:44:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1261813#M66944</guid>
      <dc:creator>AliTurabHani</dc:creator>
      <dc:date>2023-02-25T23:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting List of Rasters By name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1262221#M66951</link>
      <description>&lt;P&gt;Can't you just build the list in python rather than using arcpy.ListRasters()? I.e., if your rasters were named as you suggested above, it would go something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;lstRasters = [] 
i = 1

while i &amp;lt; 90:
	if i &amp;lt; 10:
		rnum = "00" + str(i)
	else:
		rnum = "0" + str(i)
	lstRasters.append(os.path.join(Terra_D, "A2021" + rnum))
	i+=1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then use lstRasters in CellStatistics. If you're working with 8-day MODIS averages rather than daily, then of course you'd modify the list index.&lt;/P&gt;&lt;P&gt;Unless I'm not understanding your question...&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 23:41:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1262221#M66951</guid>
      <dc:creator>ChrisRingo</dc:creator>
      <dc:date>2023-02-27T23:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting List of Rasters By name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1262540#M66958</link>
      <description>&lt;P&gt;Yes that would also work as I just want to separate rasters 1 to 90, 90 to 180, and so on (only from the daytime rasters). Would you be kind enough to explain the above code ? How would I specify the output path ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes I am working with 8 day MODIS averages. The first image is A2021001 and the next is A2021009 and so on. What do you mean by modifying the list index ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 16:41:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1262540#M66958</guid>
      <dc:creator>AliTurabHani</dc:creator>
      <dc:date>2023-02-28T16:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting List of Rasters By name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1264515#M66986</link>
      <description>&lt;P&gt;Sorry, I didn't phrase that correctly - I meant the loop index, not list index - if you are using the 8-day MODIS, then you'd need to replace the last line with "i+=8" instead of "i+=1"&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 15:19:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1264515#M66986</guid>
      <dc:creator>ChrisRingo</dc:creator>
      <dc:date>2023-03-06T15:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting List of Rasters By name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1265861#M67046</link>
      <description>&lt;P&gt;Got it. Thanks very much.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 02:24:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-list-of-rasters-by-name/m-p/1265861#M67046</guid>
      <dc:creator>AliTurabHani</dc:creator>
      <dc:date>2023-03-09T02:24:57Z</dc:date>
    </item>
  </channel>
</rss>

