ArcGIS Desktop

  • Documentation
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Set Null

Available with Spatial Analyst license.

  • Summary
  • Illustration
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Set Null sets identified cell locations to NoData based on a specified criteria. It returns NoData if a conditional evaluation is true, and returns the value specified by another raster if it is false.

Learn more about setting cell values to NoData with Set Null

Illustration

Set Null illustration
OutRas = SetNull(InRas1, InRas2, "Value = 4")

Usage

  • If the evaluation of the where clause is true, the cell location on the output raster will be assigned NoData. If the evaluation is false, the output raster will be defined by the input false raster or constant value.

  • If no where clause is specified, the output raster will have NoData wherever the conditional raster is not 0.

  • The input conditional raster does not affect whether the output data type is integer or floating point. If the input false raster (or constant value) contains floating-point values, the output raster will be floating point. If it contains all integer values, the output will be an integer raster.

  • The Expression uses an SQL query. See the following topics for more details on creating queries in the Query Builder:

    • Building a query expression
    • SQL reference for query expressions used in ArcGIS

  • In order to use a {where_clause} in Python, it should be enclosed in quotes. For example, "Value > 5000".

    You can consult the help for more information on specifying a query in Python.

  • The maximum length of the logical expression is 4,096 characters.

  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

Syntax

SetNull (in_conditional_raster, in_false_raster_or_constant, {where_clause})
ParameterExplanationData Type
in_conditional_raster

Input raster representing the true or false result of the desired condition.

It can be of integer or floating point type.

Raster Layer
in_false_raster_or_constant

The input whose values will be used as the output cell values if the condition is false.

It can be an integer or a floating point raster, or a constant value.

Raster Layer; Constant
where_clause
(Optional)

A logical expression that determines which of the input cells are to be true or false.

The expression follows the general form of an SQL expression. An example of a where_clause is "VALUE > 100".

SQL Expression

Return Value

NameExplanationData Type
out_raster

The output raster.

If the conditional evaluation is true, NoData is returned. If false, the value of the second input raster is returned.

Raster

Code sample

SetNull example 1 (Python window)

In this example, any input cell with a value less than 0 will be set to NoData in the output raster, and the remaining cells will retain their original value.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outSetNull = SetNull("elevation", "elevation", "VALUE < 0")
outSetNull.save("C:/sapyexamples/output/outsetnull.img")
SetNull example 2 (stand-alone script)

In this example, any input cell with a value other than 7 will be set to NoData, and cells that are 7 will be set to value 1 on the output.

# Name: SetNull_Ex_02.py
# Description: Returns NoData if a conditional evaluation is 
#              true and returns the value specified by another
#              raster if it is false, on a cell-by-cell basis.
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inRaster = "landclass"
inFalseRaster = 1
whereClause = "VALUE <> 7"

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Execute SetNull
outSetNull = SetNull(inRaster, inFalseRaster, whereClause)

# Save the output 
outSetNull.save("C:/sapyexamples/output/outsetnull")

Environments

  • Auto Commit
  • Cell Size
  • Compression
  • Current Workspace
  • Extent
  • Geographic Transformations
  • Mask
  • Output CONFIG Keyword
  • Output Coordinate System
  • Scratch Workspace
  • Snap Raster
  • Tile Size

Licensing information

  • ArcGIS Desktop Basic: Requires Spatial Analyst
  • ArcGIS Desktop Standard: Requires Spatial Analyst
  • ArcGIS Desktop Advanced: Requires Spatial Analyst

Related topics

  • An overview of the Conditional toolset

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2017 Esri. | Privacy | Legal