Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am really hoping that someone out there who knows a bit about ArcPy in ArcGIS10 can help me out. I am attempting to automate some work w/ netcdf files. Basically, I am able to automate the creation of the netcdf into a raster with arcpy.MakeNetCDFRasterLayer_md. However, I would simply like to then in the same python script save this layer out to a geotiff on my disk so that I can use it later in some analysis. Manually, I know I can go to the TOC right-click and export to geotiff, but it would be great to be able to script this. Any help would be greatly appreciated. I have pasted my arcpy code below for anyone’s reference which works to add the netcdf as a raster to the TOC, but I am stuck after that.


import arcpy

arcpy.env.workspace = "C:/data/NEMAC/Projects/NCA/ArcGISScripting/ArcPy"

mxd = arcpy.mapping.MapDocument("CURRENT")

# Local variables:
crcm_ccsm_cdd_mean_nc = "C:\\Data\\NEMAC\\Projects\\NCA\\NCANetcdfProcessing\\output_files\\crcm_ccsm_cdd_mean.nc"
outputRaster = "C:\\Data\\NEMAC\\Projects\\NCA\\ArcGISScripting\\ArcPy\\result1_Layer3.tif"

# Process: Make NetCDF Raster Layer
test = arcpy.MakeNetCDFRasterLayer_md(crcm_ccsm_cdd_mean_nc, "result1", "xc", "yc", outputRaster, "", "", "BY_VALUE")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
addLayer = arcpy.mapping.Layer(r"C:\Data\NEMAC\Projects\NCA\ArcGISScripting\ArcPy\result1_Layer3.tif")
arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")
lyr = arcpy.mapping.ListLayers(mxd, "", df)[0].name
#arcpy.mapping.ExportToTIFF(lyr, r"C:\Data\NEMAC\Projects\NCA\ArcGISScripting\ArcPy\result1_Layer3.tif"
del mxd, addLayer
#arcpy.SaveToLayerFile_management("C:\\Data\\NEMAC\\Projects\\NCA\\ArcGISScripting\\ArcPy\\result1_Layer3.tif", "C:\\Data\\NEMAC\\Projects\\NCA\\ArcGISScripting\\ArcPy\\result1_Layer3.tif", "ABSOLUTE")
share|improve this question
Do you actually need to add them to ArcMap, i.e. for display or checking, before you convert to TIFF? –  Luke Mar 30 '12 at 1:54

1 Answer 1

up vote 3 down vote accepted

If you don't need to add the netcdf layer to ArcMap, skip the add to ArcMap TOC step and convert straight to tif:

# Local variables:
crcm_ccsm_cdd_mean_nc = "C:\\Data\\NEMAC\\Projects\\NCA\\NCANetcdfProcessing\\output_files\\crcm_ccsm_cdd_mean.nc"
outputRaster = "result1_Layer3.tif"

# Process: Make NetCDF Raster Layer
result = arcpy.MakeNetCDFRasterLayer_md(crcm_ccsm_cdd_mean_nc, "result1", "xc", "yc", nc_lyr, "", "", "BY_VALUE")
result = arcpy.CopyRaster_management(nc_lyr,outputRaster)
share|improve this answer
Luke, this worked great. Thanks so much. –  geo derek Mar 30 '12 at 12:12
@geoderek Then click the check to accept this answer. See meta.stackexchange.com/a/5235 if you're not sure how to accept an answer. Of course you might want to wait and see if better answers get posted, that's ok too. –  Luke Jun 20 '13 at 2:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.