Skip To Content

Compute Segment Attributes

Available with Spatial Analyst license.

Available with Image Analyst license.

Summary

Computes a set of attributes associated with the segmented image. The input raster can be a single-band or 3-band, 8-bit segmented image.

Usage

  • This tool generates the attributes for each segment that exists in the image. Attributes include mean, standard deviation, segment size, converged color (from the Segment Mean Shift tool), and compactness.

Syntax

ComputeSegmentAttributes(in_segmented_raster, {in_additional_raster}, {used_attributes})
ParameterExplanationData Type
in_segmented_raster

The input segmented raster dataset, where all the pixels belonging to a segment have the same converged RGB color. Usually, it is an 8-bit, 3-band RGB raster, but it can also be a 1-band grayscale raster.

Raster Layer; Mosaic Layer
in_additional_raster
(Optional)

Incorporate ancillary raster datasets, such as a multispectral image or a DEM, to generate attributes and other required information for the classifier. This raster will be needed when calculating attributes such as mean or standard deviation. This parameter is optional.

Raster Layer; Mosaic Layer
used_attributes
[used_attributes,...]
(Optional)

Specifies the attributes to be included in the attribute table associated with the output raster.

  • COLORThe RGB color values are derived from the input raster, on a per-segment basis.
  • MEANThe average digital number (DN), derived from the optional pixel image, on a per-segment basis.
  • STDThe standard deviation, derived from the optional pixel image, on a per-segment basis.
  • COUNTThe number of pixels comprising the segment, on a per-segment basis.
  • COMPACTNESSThe degree to which a segment is compact or circular, on a per-segment basis. The values range from 0 to 1, where 1 is a circle.
  • RECTANGULARITYThe degree to which the segment is rectangular, on a per-segment basis. The values range from 0 to 1, where 1 is a rectangle.

If the only input into the tool is a segmented image, the default attributes are COLOR, COUNT, COMPACTNESS, and RECTANGULARITY. If an in_additional_raster is also included as an input along with a segmented image, then MEAN and STD are available as options.

String

Return Value

NameExplanationData Type
out_index_raster_dataset

The output segment index raster, where the attributes for each segment are recorded in the associated attribute table.

Raster

Code sample

ComputeSegmentAttributes example 1 (Python window)

This example computes segment attributes for a TIFF raster.

import arcpy
from arcpy.ia import *

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

compute_att = ComputeSegmentAttributes(
                  "c:/test/moncton_seg.tif", "c:/test/moncton.tif", 
                  "COLOR;MEAN;STD;COUNT;COMPACTNESS;RECTANGULARITY")

compute_att.save("c:/test/moncton_computeseg.tif")
ComputeSegmentAttributes example 2 (stand-alone script)

This example computes segment attributes for a TIFF raster.

# Import system modules
import arcpy
from arcpy.ia import *


"""
Usage: ComputeSegmentAttributes(in_segmented_raster, {in_additional_raster}, 
                               {used_attributes})
"""

# Set local variables
inSegRaster = "c:/test/moncton_seg.tif"
in_additional_raster = "c:/test/moncton.tif"
attributes = "COLOR;MEAN;STD;COUNT;COMPACTNESS;RECTANGULARITY"

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

# Execute 
compute_att = ComputeSegmentAttributes(inSegRaster, in_additional_raster, 
                                       attributes)
#save output 
compute_att.save("c:/test/moncton_computeseg.tif")

Licensing information

  • Basic: Requires Image Analyst or Spatial Analyst
  • Standard: Requires Image Analyst or Spatial Analyst
  • Advanced: Requires Image Analyst or Spatial Analyst

Related topics