5

I am trying to programmatically access the NoData value in a raster dataset as shown in the screenshot.

enter image description here

Two tools that come to mind to describe raster properties do not seem to be able to describe the NoData value: Describe and Get Raster Properties (Data Management).

How can I programmatically access (i.e. print) the NoData value of a raster?

6

per comments - it seems the raster band properties contain a read-only no data property.

import arcpy

desc=arcpy.Describe('rasterName')
print desc.noDataValue

resulted in a value of -3.40282346639e+38 on a single bad ESRI binary grid that i had lying around.

thanks!

5

I found the solution on an ESRI blog. The idea is to convert the raster to a raster object and then access the specific NoData value with .noDataValue.

import arcpy
arcpy.env.workspace = r'C:\temp'

rasterList = arcpy.ListRasters()

for raster in rasterList:
    rasterObj = arcpy.Raster(raster)
    noData = rasterObj.noDataValue

    print "NoData Value: %s \n" %noData
  • 1
    interesting. it might vary with the version of arc - but this says that the no data value is a read only property - perhaps only for multi-band rasters? – fluidmotion Aug 22 '14 at 18:06
  • Good call @fluidmotion--it appearas as if the documentation is different between 10.1 and 10.2. I would be happy to accept your answer if you write it up and provide an example of the .noDataValue in action. Thanks. – Aaron Aug 22 '14 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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