Rank (Spatial Analyst)
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.
-
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.
Syntax
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
This example performs a rank operation on several input GRID rasters and outputs the result as an 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")
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 # Author: ESRI # 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")