Skip To Content


Available with Spatial Analyst license.


The values from the set of input rasters are ranked on a cell-by-cell basis, and which of these gets returned is determined by the value of the rank input raster.


Rank illustration
OutRas = Rank(ConstRas, [InRas1, InRas2, InRas3])


  • In the list of input rasters, the order is irrelevant. However, the Rank input raster must precede these.

  • An arbitrary number of rasters can be specified in the input rasters list.

  • If a cell location contains NoData on any of the input rasters, that location will be assigned NoData on the output.

  • If all of the input values are the same for any cell location, regardless of the specified rank, the output for that cell location will be that value.

  • If the rank raster value is greater than the number of input rasters, each cell location on the output will be assigned NoData.

  • If any of the input rasters are floating point, the output is floating point; otherwise, it is integer.

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


Rank (in_rank_raster_or_constant, in_rasters)
ParameterExplanationData Type

The input raster that defines the rank position to be returned.

A number can be used as an input; however, the cell size and extent must first be set in the environment.

Raster Layer; Constant

The list of input rasters.

The input defines the argument list to identify the value for the rank, defined by the first argument for each cell location.

Raster Layer

Return Value

NameExplanationData Type

The output raster.

For each cell in the output raster, the values in the input rasters are sorted from lowest to highest, and the input rank raster's value is used to select which will be the output value.


Code sample

Rank example 1 (Python window)

This example performs a rank operation on several input Grid rasters and outputs the result as a TIFF raster.

import arcpy
from arcpy import env
from import *
env.workspace = "C:/sapyexamples/data"
outRank = Rank("cost", ["degs", "negs", "fourgrd"])"C:/sapyexamples/output/outrank.tif")
Rank example 2 (stand-alone script)

This example performs a rank operation on several input Grid rasters and outputs the result as a Grid raster.

# Name:
# Description: Returns the value of a set of rasters based on
#              a rank level specified by another raster 
# Requirements: Spatial Analyst Extension

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

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

# Set local variables
inRankRaster = "cost"
inRaster01 = "degs"
inRaster02 = "negs"
inRaster03 = "fourgrd"

# Execute Rank
outRank = Rank(inRankRaster, [inRaster01, inRaster02, inRaster03])

# Save the output"C:/sapyexamples/output/outrank")

Licensing information

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

Related topics