Eliminate 1.#QNAN values from raster datasets

Last Published: April 25, 2020


QNAN meaning 'quiet not a number' sometimes exists in raster data. Map algebra can be used to eliminate QNAN values ('1.#QNAN') from appearing in raster datasets.Instructions provided describe how to eliminate 1.#QNAN values.


To eliminate these values, map algebra can be used in conjunction with Python to automate the process.

The following Python script queries the number of bands within the raster dataset, performs map algebra on each individual band to eliminate the 1.#QNAN values, and creates a new raster.


#Eliminate QNAN values based on band count
#Import modules
import arcpy, string, os, time
from arcpy import env
from import *

#Checkout extensions

#Define path to raster
raster = "E:/Rasters/Rasters/4_band/po_120780_4bands.tif"

#Define/set initial workspace/create workspaces
workspace = "C:/Delete" # set initial space
tempspace = workspace + os.sep + "tempspace"
finalspace = workspace + os.sep + "finalspace"

if not os.path.exists(tempspace):
if not os.path.exists(finalspace):

#Get bandcount
BndCnt = arcpy.GetRasterProperties_management(raster, "BANDCOUNT")

#create value table
vt = arcpy.ValueTable()

#describe raster /basename /composite name
desc_ras = arcpy.Describe(raster)
name = desc_ras.baseName
CompositeRas = finalspace + os.sep + name + ".tif"

# Band count
Xcnt = str(BndCnt)
print Xcnt
count = 1

#Loop based on band count and set each band to itself else set to 0
while count <= int(Xcnt):

bnd = raster + "\Band_" + str(count)
tempname = tempspace + os.sep + name + "Band_" + str(count) + ".tif"
ma = Con(Raster(bnd) == Raster(bnd), bnd, 0)
print ("completed map algebra on band: " + str(count))
count = count + 1

arcpy.env.workspace = tempspace
rasterList = arcpy.ListRasters()

for rasters in rasterList:
print rasters

arcpy.CompositeBands_management(vt, CompositeRas)
print "completed composite"

del count, BndCnt, Xcnt, rasters, rasterList, bnd, ma, tempname, name, desc_ras, vt

Article ID:000011443

  • ArcMap

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic