Available with Spatial Analyst license.
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
Usage
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.
When a multiband raster is specified for the Input rank raster or constant value (in_rank_raster_or_constant in Python), only the first band will be used. To process a different band, specify the specific band to use.
When a multiband raster is specified as one of the Input rasters (in_rasters in Python), all the bands will be used.
To process a selection of bands from a multiband raster, you can first create a new raster dataset composed of those particular bands with the Composite Bands tool, and use the result in the list of the Input rasters (in_rasters in Python).
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.
Syntax
Rank(in_rank_raster_or_constant, in_rasters)
Parameter | Explanation | Data 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
Name | Explanation | Data 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
Licensing information
- Basic: Requires Spatial Analyst
- Standard: Requires Spatial Analyst
- Advanced: Requires Spatial Analyst