Popularity (Spatial Analyst)

License Level:BasicStandardAdvanced

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

Popularity illustration
OutRas = Popularity(ValRas, [InRas1, InRas2, InRas3])

Usage

Syntax

Popularity (in_popularity_raster_or_constant, in_rasters)
ParameterExplanationData 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

NameExplanationData 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

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