Rank (Spatial Analyst)

License Level:BasicStandardAdvanced

Summary

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.

Illustration

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

Usage

Syntax

Rank (in_rank_raster_or_constant, in_rasters)
ParameterExplanationData Type
in_rank_raster_or_constant

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
in_rasters
[in_raster,...]

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
out_raster

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.

Raster

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 arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outRank = Rank("cost", ["degs", "negs", "fourgrd"])
outRank.save("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: Rank_Ex_02.py
# 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 arcpy.sa import *

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

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

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

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

# Save the output 
outRank.save("C:/sapyexamples/output/outrank")

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Requires Spatial Analyst
ArcGIS for Desktop Standard: Requires Spatial Analyst
ArcGIS for Desktop Advanced: Requires Spatial Analyst
4/10/2014