msknowles

nodata option in CopyRaster

Discussion created by msknowles on Aug 19, 2013
Latest reply on Aug 21, 2013 by msknowles
I'm working with a NETCDF file and am running the following code and the nodata option of the CopyRaster command doesn't appear to be working as I expect.  The CopyRaster successfully creates the raster but in the properties the maximum value is still displayed as the value in the CopyRaster command.  I've also tried entering the 36-digit number instead of the scientific notation and I get the same result.  I'm not sure if it's the large value that's the problem or if I'm overlooking something.

The nc variable I'm working with has the large value for water bodies and the remaining cells between 0-1 (floating point) so if the nodata option worked I'd expect a max <= 1.

import arcpy
from arcpy import env
arcpy.CheckOutExtension("spatial")
from arcpy.sa import *
arcpy.env.overwriteOutput = True

arcpy.env.workspace = r"G:\data\NETCDF"
NetCDFFile = r"G:\data\NETCDF\year.nc"
GDB = r"G:\data\NETCDF\GCM\Hist_Output_Part_Burn4.gdb"
NetCDFFileProp = arcpy.CreateObject("NetCDFFileProperties", NetCDFFile)

##for i in range(0,int(NetCDFFileProp.getDimensionSize("year"))):
for i in range(0,1):
## # convert month from a floating point to an integer (prevents error in naming raster)
 DIMENSION_VALUE = int(NetCDFFileProp.getDimensionValue("year",i))
 print 'Working on Dimension Value: ', DIMENSION_VALUE, '(index ', i, ')'

 # delete existing raster if it exists
 if arcpy.Exists( GDB + "\\" + "year" + str(DIMENSION_VALUE )):
  print '--- deleting ', "year" + str(DIMENSION_VALUE)
  arcpy.Delete_management( GDB + "\\" + "year" + str(DIMENSION_VALUE ))
 # create raster layer from NetCDF file
 arcpy.MakeNetCDFRasterLayer_md(NetCDFFile, "part_burn", "lon", "lat", "year_"+str(i), "", "year " + str(DIMENSION_VALUE))

 # create raster
 arcpy.CopyRaster_management("year_"+str(i), GDB + "\\" + "Hist_PB_"+str(DIMENSION_VALUE+1895), "", "", "9.96921e+036")

 #reclass raster
#Notify when finished
print "Finished!"


Thanks,
Mike

Outcomes