Available with Spatial Analyst license.
Summary
Determines the value in an argument list that is at a certain level of popularity on a cell-by-cell basis. The particular level of popularity (the number of occurrences of each value) is specified by the first argument.
Illustration
Usage
The tool evaluates the number of occurrences of the input raster values for each location and ranks them on an ordinal scale—that is, the most popular, second most popular, and so on. It will return the value of the specified nth most popular value defined by the popularity raster value.
In the list of input rasters, the order is irrelevant. However, the raster that defines the popularity position must precede these.
An arbitrary number of rasters can be specified in the input rasters list.
If the input values are the same for any cell location, regardless of the specified popularity, the output value will be the same as the input for that cell location.
When a multiband raster is specified for the Input popularity raster or constant value (in_popularity_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 there is no single value found to be the nth most popular, NoData will be assigned to the location on the output raster. This situation occurs when all input raster values at a location are different or when two or more input raster values have the same number of occurrences and that number is the nth most popular. Returning one of the input raster values, such as the first one encountered in the scan process, would be deceptive. You would not know whether the value is truly the nth most popular value.
If the popularity value is greater than the number of input rasters, each cell location on the output will be assigned NoData.
If 0 is specified as the popularity value, the output value will be NoData.
A popularity level of 1 is the majority value, similar to the Majority option of the Cell Statistics tool.
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
Popularity(in_popularity_raster_or_constant, in_rasters)
Parameter | Explanation | Data Type |
in_popularity_raster_or_constant | The input raster defining the popularity 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 used to evaluate the popularity of the values for each cell location. | Raster Layer |
Return Value
Name | Explanation | Data Type |
out_raster | The output raster. Each cell in the output raster represents the value from the same location of input rasters that meets the input popularity value. | Raster |
Code sample
Popularity example 1 (Python window)
This example performs a popularity operation on several input rasters and outputs the result as an IMG raster.
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outPopularity = Popularity("cost", ["degs", "negs", "fourgrd"])
outPopularity.save("C:/sapyexamples/output/outpop.img")
Popularity example 2 (stand-alone script)
This example performs a popularity operation on several input rasters and outputs the result as a Grid raster.
# Name: Popularity_Ex_02.py
# Description: Determines the value in an argument list that is
# at a certain level of popularity
# 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
inPopularityRaster = "cost"
inRaster01 = "degs"
inRaster02 = "negs"
inRaster03 = "fourgrd"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute Popularity
outPopularity = Popularity(inPopularityRaster, [inRaster01, inRaster02, inRaster03])
# Save the output
outPopularity.save("C:/sapyexamples/output/outpop")
Environments
Licensing information
- Basic: Requires Spatial Analyst
- Standard: Requires Spatial Analyst
- Advanced: Requires Spatial Analyst