HOW TO

Clear NaN Values from Raster Layers

Last Published: February 27, 2025

Summary

NaN (Not a Number) is a value attributed to pixels in a raster that are irrelevant to the data in an image. Similar to NoData values, they may be visible within the raster with an assigned colour value, but they do not represent a data value in the raster layer for inspection or analysis.

In the image below, a raster layer is overlayed on a geographic style basemap. The lighter sections indicate a value distribution over a surface, but many of the darker sections at the edge of the raster are NaN values.

NaN values in a Raster Layer in ArcGIS Pro

When performing analysis, you may wish to remove these NaN values. However, as these are not number values, it is not as simple as when the values are 'NoData' values.

Procedure

The solution is to clear NaN values by converting them to NoData values, using the Raster Calculator to multiply the values of each cell by 1, or by using the Set Null tool, as follows:

Note:
An ArcGIS Pro Spatial Analyst or Image Analyst license is required.

Using the Raster Calculator

  1. In ArcGIS Pro, open the Geoprocessing Pane, Analysis tab > Tools.
  2. Search for Raster Calculator and open the tool, Image Analyst Tools > Map Algebra > Raster Calculator.
  3. In the Raster Calculator expression field, add the Raster layer name followed by * 1.

Raster Calculator

  1. Click Run and wait for the new raster layer to be created.
  2. Transparency of the NoData values should be automatically applied. Click in a previous NaN value section as shown in the first image above, and confirm the data value change in the pop-up window.

Using Set Null

  1. Open the Set Null geoprocessing tool, Image Analyst Tools > Math > Conditional.
  2. On the Parameters tab, set the Input conditional raster as a raster dataset with NAN values.
  3. For the Expression, set Where VALUE is Null.
  4. Under Input false raster or constant value, set this to be the same as the Input conditional raster.
  5. Set the Output raster dataset name and path.
  6. Run the tool.

raster calculator inputs

Article ID: 000034222

Software:
  • ArcGIS Pro

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options