<?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: Batch Processing for Make NetCDF Raster Layer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84866#M6695</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This type of task is very common in GIS work and, fortunately, requires only a very simple script. Your first step should be to read the documentation and make sure you understand what information you need to run the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//004300000006000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;MakeNetCDFRasterLayer&lt;/A&gt;&lt;SPAN&gt; tool. Then start with this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy as ap
import glob

# this will give you a Python list object that you can use to batch process all of your files
# just insert the path to your folder holding the netCDF files
cdfList = glob.glob('C:\\examplefolder\\*.nc')

# now you can loop through your list and process each file one at a time
for cdf in cdfList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Now processing: " + cdf
&amp;nbsp;&amp;nbsp;&amp;nbsp; ap.md.MakeNetCDFRasterLayer(cdf, [fill in the other variables here])
print "Done!"&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that this is only the start of the script. For example, you'll need to make sure each output raster is given a unique, meaningful name. But we should leave some of the fun stuff for you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 23:15:41 GMT</pubDate>
    <dc:creator>PhilMorefield</dc:creator>
    <dc:date>2021-12-10T23:15:41Z</dc:date>
    <item>
      <title>Batch Processing for Make NetCDF Raster Layer</title>
      <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84862#M6691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have hundreds of netcdf files and I need to convert them into grid format permanently. Instead of going through each netcdf files and converting them into grid and making them permanent, I am trying to batch this process. But, due to limited knowledge in python, I am having hard time in achieving this target. Has anyone run into this problem and come up with the solution?. I will really appreciate your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sami&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Apr 2011 12:52:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84862#M6691</guid>
      <dc:creator>fabefabe</dc:creator>
      <dc:date>2011-04-23T12:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Processing for Make NetCDF Raster Layer</title>
      <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84863#M6692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would like help with this too, let me know if you find a way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2011 03:21:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84863#M6692</guid>
      <dc:creator>SarahBurns</dc:creator>
      <dc:date>2011-05-20T03:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Processing for Make NetCDF Raster Layer</title>
      <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84864#M6693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried right-clicking the tool and choose the 'Batch' option?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2011 17:27:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84864#M6693</guid>
      <dc:creator>RafaGutierrez</dc:creator>
      <dc:date>2011-06-01T17:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Processing for Make NetCDF Raster Layer</title>
      <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84865#M6694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Have you tried right-clicking the tool and choose the 'Batch' option?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like you still have to enter each netcdf file separately? Not very useful for 500 of them.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 May 2012 20:50:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84865#M6694</guid>
      <dc:creator>PamFroemke</dc:creator>
      <dc:date>2012-05-24T20:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Processing for Make NetCDF Raster Layer</title>
      <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84866#M6695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This type of task is very common in GIS work and, fortunately, requires only a very simple script. Your first step should be to read the documentation and make sure you understand what information you need to run the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//004300000006000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;MakeNetCDFRasterLayer&lt;/A&gt;&lt;SPAN&gt; tool. Then start with this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy as ap
import glob

# this will give you a Python list object that you can use to batch process all of your files
# just insert the path to your folder holding the netCDF files
cdfList = glob.glob('C:\\examplefolder\\*.nc')

# now you can loop through your list and process each file one at a time
for cdf in cdfList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Now processing: " + cdf
&amp;nbsp;&amp;nbsp;&amp;nbsp; ap.md.MakeNetCDFRasterLayer(cdf, [fill in the other variables here])
print "Done!"&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that this is only the start of the script. For example, you'll need to make sure each output raster is given a unique, meaningful name. But we should leave some of the fun stuff for you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:15:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84866#M6695</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2021-12-10T23:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Processing for Make NetCDF Raster Layer</title>
      <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84867#M6696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is&amp;nbsp; my code. I got it to loop through every file in a folder. The problem is that it only reads the first value. I haven't figured out how to loop through each individual value in the netCDF file yet. I have been trying to modify the code from this forum: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/32361-using-arcpy-to-export-separate-netcdf-dimension-values-as-a-raster" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/32361-using-arcpy-to-export-separate-netcdf-dimension-values-as-a-raster&lt;/A&gt;&lt;SPAN&gt; so it reads individual value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Input data source
arcpy.env.workspace = "S:/PM_data/Climate_Idaho/Raw/pr"
arcpy.env.overwriteOutput = True

# Set output folder
OutputFolder = "S:/PM_data/Climate_Idaho/Output/pr_raster"


# Loop through a list of files in the workspace
NCfiles = arcpy.ListFiles("*.nc")

for filename in NCfiles:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Processing: " + filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp; inNCfiles = arcpy.env.workspace + "/" + filename
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileroot = filename[0:(len(filename)-3)]
&amp;nbsp;&amp;nbsp;&amp;nbsp; TempLayerFile = "precipitation_amount"
&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = OutputFolder + "/" + fileroot

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Make NetCDF Raster Layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeNetCDFRasterLayer_md(inNCfiles, "precipitation_amount", "lon", "lat", TempLayerFile, "", "", "BY_VALUE")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Copy Raster
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyRaster_management(TempLayerFile, outRaster + ".tif", "", "", "", "NONE", "NONE", "")
&amp;nbsp;&amp;nbsp; 

print "***DONE!!!"
print arcpy.GetMessages()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:15:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84867#M6696</guid>
      <dc:creator>RPatarasuk</dc:creator>
      <dc:date>2021-12-10T23:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Processing for Make NetCDF Raster Layer</title>
      <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84868#M6697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This is&amp;nbsp; my code. I got it to loop through every file in a folder. The problem is that it only reads the first value. I haven't figured out how to loop through each individual value in the netCDF file yet. I have been trying to modify the code from this forum: &lt;A href="http://forums.arcgis.com/threads/32361-using-arcpy-to-export-separate-netcdf-dimension-values-as-a-raster" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/32361-using-arcpy-to-export-separate-netcdf-dimension-values-as-a-raster&lt;/A&gt; so it reads individual value.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Input data source
arcpy.env.workspace = "S:/PM_data/Climate_Idaho/Raw/pr"
arcpy.env.overwriteOutput = True

# Set output folder
OutputFolder = "S:/PM_data/Climate_Idaho/Output/pr_raster"


# Loop through a list of files in the workspace
NCfiles = arcpy.ListFiles("*.nc")

for filename in NCfiles:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Processing: " + filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp; inNCfiles = arcpy.env.workspace + "/" + filename
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileroot = filename[0:(len(filename)-3)]
&amp;nbsp;&amp;nbsp;&amp;nbsp; TempLayerFile = "precipitation_amount"
&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = OutputFolder + "/" + fileroot

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Make NetCDF Raster Layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeNetCDFRasterLayer_md(inNCfiles, "precipitation_amount", "lon", "lat", TempLayerFile, "", "", "BY_VALUE")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Copy Raster
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyRaster_management(TempLayerFile, outRaster + ".tif", "", "", "", "NONE", "NONE", "")
&amp;nbsp;&amp;nbsp; 

print "***DONE!!!"
print arcpy.GetMessages()&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that you need to call arcpy.MakeNetCDFRasterLayer_md() for each time step in each netCDF file. You're looping through your files fine, but you need to add another 'inner' loop to go through an individual file. I would try to use "BY_INDEX" instead of "BY_VALUE". Let's assume that your data are in time series, so the "dimension value" is "TIME":&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# this will convert the FIRST time step in your netCDF file to a raster layer
arcpy.MakeNetCDFRasterLayer_md(inNCfiles, "precipitation_amount", "lon", "lat", TempLayerFile1, "#", "TIME 0", "BY_INDEX")

# this will convert the SECOND time step in your netCDF file to a raster layer
arcpy.MakeNetCDFRasterLayer_md(inNCfiles, "precipitation_amount", "lon", "lat", TempLayerFile2, "#", "TIME 1", "BY_INDEX")

# this will convert the THIRD time step in your netCDF file to a raster layer
arcpy.MakeNetCDFRasterLayer_md(inNCfiles, "precipitation_amount", "lon", "lat", TempLayerFile3, "#", "TIME 2", "BY_INDEX")

#and so on...&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Obviously you can't just copy-and-paste this code, but this should give you an idea of how to set it up.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:15:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84868#M6697</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2021-12-10T23:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Processing for Make NetCDF Raster Layer</title>
      <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84869#M6698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This type of task is very common in GIS work and, fortunately, requires only a very simple script. Your first step should be to read the documentation and make sure you understand what information you need to run the &lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//004300000006000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;MakeNetCDFRasterLayer&lt;/A&gt; tool. Then start with this:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy as ap
import glob

# this will give you a Python list object that you can use to batch process all of your files
# just insert the path to your folder holding the netCDF files
cdfList = glob.glob('C:\\examplefolder\\*.nc')

# now you can loop through your list and process each file one at a time
for cdf in cdfList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Now processing: " + cdf
&amp;nbsp;&amp;nbsp;&amp;nbsp; ap.md.MakeNetCDFRasterLayer(cdf, [fill in the other variables here])
print "Done!"&lt;/PRE&gt;&lt;BR /&gt;Note that this is only the start of the script. For example, you'll need to make sure each output raster is given a unique, meaningful name. But we should leave some of the fun stuff for you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you! I meant to write earlier that this script idea worked like a charm. I used an inner loop with Select by Dimension to evaluate each month in each netcdf file. I noticed you had a different method elsewhere in this thread. I'll try that next time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Pam&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PS - I can't find the 'green checkmark' that is supposed to indicate this answered my question so I'll just say, "This answered my question!".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:15:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84869#M6698</guid>
      <dc:creator>PamFroemke</dc:creator>
      <dc:date>2021-12-10T23:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Processing for Make NetCDF Raster Layer</title>
      <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84870#M6699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thank you! I meant to write earlier that this script idea worked like a charm. I used an inner loop with Select by Dimension to evaluate each month in each netcdf file. I noticed you had a different method elsewhere in this thread. I'll try that next time.&lt;BR /&gt;Thanks again,&lt;BR /&gt;Pam&lt;BR /&gt;PS - I can't find the 'green checkmark' that is supposed to indicate this answered my question so I'll just say, "This answered my question!".&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Great! I'll also mention that, compared to third-party Python packages, processing netCDF data in ArcGIS is very, very slow (sorry ESRI). For big jobs, or for folks working with netCDF data regularly, I would recommend &lt;/SPAN&gt;&lt;A href="http://dirac.cnrs-orleans.fr/plone/software/scientificpython/"&gt;ScientificPython&lt;/A&gt;&lt;SPAN&gt;. That way you can work with each step in the 'time' dimension as a numpy array, do whatever averaging or calculation is needed, and just use ArcGIS at the end to produce your GIS-friendly output.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 14:25:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84870#M6699</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2012-06-20T14:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Processing for Make NetCDF Raster Layer</title>
      <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84871#M6700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I got a better code now but it's not really perfect yet&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Make a separate raster *.img file for each dimension value (time) in a netcdf file

import arcpy, os, time, datetime, calendar
from arcpy import env
from arcpy.sa import *

# Input data source

#########Change folder
arcpy.env.workspace = "S:/PM_data/Climate_Idaho/Raw/tmmx" # Change folder++
#########

arcpy.env.overwriteOutput = True
arcpy.env.scratchWorkspace = "S:/Work/Risa/Trials_Errors/ScratchWorkSpace"

# Loop through a list of files in the workspace
NetCDFfiles = arcpy.ListFiles("*.nc")

for filename in NetCDFfiles:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Processing: " + filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set local variables
&amp;nbsp;&amp;nbsp;&amp;nbsp; inNetCDF = arcpy.env.workspace + "/" + filename

#########Change the variable
&amp;nbsp;&amp;nbsp;&amp;nbsp; variable = "air_temperature" 
#########
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; XDimension = "lon"
&amp;nbsp;&amp;nbsp;&amp;nbsp; YDimension = "lat"
&amp;nbsp;&amp;nbsp;&amp;nbsp; bandDimension = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; dimensionValues = "day "
&amp;nbsp;&amp;nbsp;&amp;nbsp; valueSelectionMethod = "BY_VALUE"

#########Change the variable ###
&amp;nbsp;&amp;nbsp;&amp;nbsp; InMemory_netcdf_raster = "air_temperature" 
#########
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#########Change folder&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; outRasterFolder = "S:/PM_data/Climate_Idaho/Output/tmmx_raster"
#########
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Global Attribute:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #ncFP = arcpy.NetCDFFileProperties(inNetCDF)
&amp;nbsp;&amp;nbsp;&amp;nbsp; #ncDim = ncFP.getDimensions()

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Get Global Attribues
&amp;nbsp;&amp;nbsp;&amp;nbsp; #ncAttributeNames = ncFP.getAttributeNames("")
&amp;nbsp;&amp;nbsp;&amp;nbsp; #for ncAttributeName in ncAttributeNames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print " "
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print "Attribute Name: %s " % ncAttributeName
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print ncFP.getAttributeValue("", ncAttributeName)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print " "
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Year info

#######change the lengths
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileroot = filename[5:(len(filename)-3)] #change the name lengths too
#######
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Yr = int(fileroot) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Processing --&amp;gt; " + str(Yr)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Month info
&amp;nbsp;&amp;nbsp;&amp;nbsp; allmnths = range(1,13)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for mnths in allmnths:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lastday = calendar.monthrange(Yr, mnths)[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRange = range(1,Lastday+1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for dyy in MRange:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dyys =int(dyy)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mnthsss = int(mnths)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a = str(mnthsss)+ "/" + str(dyys) +"/" + str(Yr)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #IF Days or Months less than 10, we want to put zero at the front so it is easier to sort.

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if mnthsss &amp;lt; 10: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = str(Yr)+ "_" + "0" + str(mnthsss)+ "_" + "0" + str(dyys)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = str(Yr)+ "_" + str(mnthsss)+ "_" + str(dyys)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if dyys &amp;lt; 10:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = str(Yr)+ "_" + "0" + str(mnthsss)+ "_" + "0" + str(dyys)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = str(Yr)+ "_" + "0" + str(mnthsss)+ "_" + str(dyys)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ##############&amp;nbsp; ####### ####### ####### ####### ####### ####### #######
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #the OUTPUT has zero in front of October, Nov, and DEc (month value &amp;gt;10)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #NEED TO FIX THIS ***
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ##############&amp;nbsp; ####### ####### ####### ####### ####### ####### #######
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dimensionValues = "day " + a
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
##########CHANGE the word too##&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #################
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outTIFF = outRasterFolder + "/" + "tmmx_" + b + ".tif"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #################

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Execute MakeNetCDFRasterLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeNetCDFRasterLayer_md(inNetCDF, variable, XDimension, YDimension, InMemory_netcdf_raster, bandDimension, dimensionValues, valueSelectionMethod)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print "Created NetCDF Layer for " + a
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Copy Raster
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyRaster_management(InMemory_netcdf_raster, outTIFF, "", "", "", "NONE", "NONE", "")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Created Raster for _tmmx_" + b
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #################
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
print "\nEnd of processing ... YAHOO!!!"
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:15:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84871#M6700</guid>
      <dc:creator>RPatarasuk</dc:creator>
      <dc:date>2021-12-10T23:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Processing for Make NetCDF Raster Layer</title>
      <link>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84872#M6701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;im trying to do the conversion discussed above but im completely new to python scripting. i copy pasted the script u posted on python idle and saved the file. then i created a script in a toolbox and tried to run it.&amp;nbsp; and it didnt run. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the netcdf data that i have is a monthly avg.i created a folder for each year and stored 12 files, 1 for each month. so i dont think i have the time dimension you mentioned&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Veg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Apr 2013 10:10:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-processing-for-make-netcdf-raster-layer/m-p/84872#M6701</guid>
      <dc:creator>vegv</dc:creator>
      <dc:date>2013-04-18T10:10:22Z</dc:date>
    </item>
  </channel>
</rss>

