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 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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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!

share|improve this answer

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
share|improve this answer
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 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 at 18:16

Your Answer

 
discard

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.