Batch processing: turning NetCDF to raster

4255
6
Jump to solution
07-10-2015 12:53 PM
awei
by
New Contributor III

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?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
IanMurray
Frequent Contributor

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.

View solution in original post

6 Replies
IanMurray
Frequent Contributor

What version of ArcGIS are you running?

For Arc 10.X, it should be ap.MakeNetCDFRasterLayer_md for the tool, not ap.md.MakeNetCDFRasterLayer

ArcGIS Desktop

0 Kudos
awei
by
New Contributor III

still nothing! weird! I know this should provide a layer file. where can I find that?

0 Kudos
awei
by
New Contributor III

I'm using 10.2.2

0 Kudos
IanMurray
Frequent Contributor

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.

awei
by
New Contributor III

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.

0 Kudos
SteveLynch
Esri Regular Contributor

it returns an in-memory raster layer. Use SaveToLayerFile_management or CopyRaster_management to persist the result.

-Steve