HOW TO

# Eliminate 1.#QNAN values from raster datasets

Last Published: April 25, 2020

## Summary

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.

## Procedure

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.

`Code:#Eliminate QNAN values based on band count#Import modulesimport arcpy, string, os, timefrom arcpy import envfrom arcpy.sa import *#Checkout extensionsarcpy.CheckOutExtension("spatial")#Define path to rasterraster = "E:/Rasters/Rasters/4_band/po_120780_4bands.tif"#Define/set initial workspace/create workspacesworkspace = "C:/Delete" # set initial spacetempspace = workspace + os.sep + "tempspace"finalspace = workspace + os.sep + "finalspace"if not os.path.exists(tempspace):    os.mkdir(tempspace)if not os.path.exists(finalspace):    os.mkdir(finalspace)#Get bandcountBndCnt = arcpy.GetRasterProperties_management(raster, "BANDCOUNT")#create value tablevt = arcpy.ValueTable()#describe raster /basename /composite namedesc_ras = arcpy.Describe(raster)name = desc_ras.baseNameCompositeRas = finalspace + os.sep + name + ".tif"# Band countXcnt = str(BndCnt)print Xcntcount = 1#Loop based on band count and set each band to itself else set to 0while 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)    ma.save(tempname)    print ("completed map algebra on band: " + str(count))    count = count + 1arcpy.env.workspace = tempspacerasterList = arcpy.ListRasters()for rasters in rasterList:    print rasters    vt.addRow(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

Software:
• ArcMap

Get help from ArcGIS experts

Contact technical support