I did a bit searching on the Internet and here's my practice:
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('F:\\NLDAS 2-primary forcing\\test\\*.nc') print cdfList # now you can loop through your list and process each file one at a time for cdf in cdfList: print "Now processing: " + cdf ap.md.MakeNetCDFRasterLayer(cdf,"pevapsfc","lon","lat",cdf+"_r") print "Done!"
It ran smoothly but I didn't see anything on my output folder. Did I do something wrong?
Solved! Go to Solution.
Are you doing this within a map document or outside?
If outside, you need to save a layer file for each one, as the help says
"To save the output layer, right-click the layer in the ArcMap table of contents and click Save As Layer File, or use the Save To Layer File tool."
Otherwise, you can change the environment settings to guarantee geoprocessing outputs are added to the map document, if it doesn't add automatically after geoprocessing.
What version of ArcGIS are you running?
For Arc 10.X, it should be ap.MakeNetCDFRasterLayer_md for the tool, not ap.md.MakeNetCDFRasterLayer
still nothing! weird! I know this should provide a layer file. where can I find that?
I'm using 10.2.2
Are you doing this within a map document or outside?
If outside, you need to save a layer file for each one, as the help says
"To save the output layer, right-click the layer in the ArcMap table of contents and click Save As Layer File, or use the Save To Layer File tool."
Otherwise, you can change the environment settings to guarantee geoprocessing outputs are added to the map document, if it doesn't add automatically after geoprocessing.
I didn't know there's a difference running code in and out of software and I found that very helpful! Thank you so much.
it returns an in-memory raster layer. Use SaveToLayerFile_management or CopyRaster_management to persist the result.
-Steve