Dimensional Moving Statistics (Spatial Analyst)

Available with Spatial Analyst license.

Available with Image Analyst license.

Summary

Calculates statistics over a moving window on multidimensional data along a specified dimension.

Usage

  • Moving statistics can also be called moving window statistics, rolling statistics, or running statistics. A predefined window around each dimension value is used to calculate various statistics before moving to the next. The Backward Window and Forward Window parameters allow you to define window sizes on both sides of the dimension.

  • The input raster can only be a multidimensional raster in Cloud Raster Format (.crf file).

  • Only one dimension will be processed by this tool. By default, the first dimension other than x,y will be used as the processing dimension.

  • The Circular Mean statistics type calculates the mean for angles or other cyclic quantities, such as compass direction in degrees. When this option is selected, the Circular Wrap Value parameter becomes available. Use this parameter to designate a value to wrap around to calculate the circular mean. For example, for angle calculation, the circular wrap value should be 360 degrees, which means the value 360 will be wrapped to 0, and the value 370 will be wrapped to 10. Another use is for time calculations of months in a year, in which case the circular wrap value should be 12. In this case, an input value of 13 will be wrapped to 1.

  • If the input multidimensional raster is integer, the valid options for Statistics Type are Mean, Circular Mean, Majority, Maximum, Median, Minimum, and Percentile. If the input raster is float, Majority is not available.

  • If the input raster is integer, the output raster will be integer for the Majority, Maximum, and Minimum options. The output will be float for Mean, Circular Mean, Median, and Percentile.

    If the input raster is of float type, the output will be float for all of the available statistic types.

  • For the Majority option, when there is a tie, the output will be the lowest of the tied values.

  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

Parameters

LabelExplanationData Type
Input Multidimensional Raster

The input raster can only be a multidimensional raster in Cloud Raster Format (.crf file).

Raster Layer
Dimension
(Optional)

The name of the dimension along which the window will move.

The default value is the first dimension other than x,y found in the input multidimensional raster.

String
Backward Window
(Optional)

The value of how many slices before or above to be included in the defined window. The value must be a positive integer from 1 to 100. The default value is 1.

The unit of this parameter is slice.

Long
Forward Window
(Optional)

The value of how many slices after or below to be included in the defined window. The value must be a positive integer from 1 to 100. The default value is 1.

The unit of this parameter is slice.

Long
NoData Handling
(Optional)

Specifies how NoData values will be handled by the statistic calculation.

  • DataNoData values in the value input will be ignored in the results of the defined window that they fall within. This is the default.
  • NoDataOutput values will be NoData if any NoData values are found in the input within the defined window.
  • Fill NoDataNoData cell values will be replaced using the selected statistic on the values within the defined window.
String
Statistics Type
(Optional)

Specifies the statistic type to be calculated.

  • MeanThe mean (average value) of the cells in the defined window will be calculated. This is the default.
  • Circular MeanThe mean for angles or other cyclic quantities—such as compass direction in degrees, daytimes, or fractional parts of real numbers—will be calculated. When this statistics type is selected, the Circular Wrap Value parameter becomes available. Use this parameter to designate a wrap value.
  • MajorityThe majority (value that occurs most often) of the cells in the defined window will be identified.
  • MaximumThe maximum (largest value) of the cells in the defined window will be identified.
  • MedianThe median of the cells in the defined window will be identified.
  • MinimumThe minimum (smallest value) of the cells in the defined window will be identified.
  • PercentileA percentile of the cells in the defined window will be calculated. The 90th percentile is calculated by default. When this statistics type is selected, the Percentile Value and Percentile Interpolation Type parameters become available. Use these new parameters to designate the percentile to calculate and choose the interpolation type to use, respectively.
String
Percentile Value
(Optional)

The percentile value that will be calculated. The default is 90, for the 90th percentile.

The value can range from 0 to 100. The 0th percentile is essentially equivalent to the minimum statistic, and the 100th percentile is equivalent to the maximum statistic. A value of 50 will produce essentially the same result as the median statistic.

This parameter is only supported if the Statistics Type parameter is set to Percentile.

Double
Percentile Interpolation Type
(Optional)

Specifies the method of interpolation that will be used when the percentile value falls between two cell values.

This parameter is only supported if the Statistics Type parameter is set to Median or Percentile.

  • Auto-detectIf the input raster is of integer pixel type, the Nearest method will be used. If the input raster is of float pixel type, the Linear method will be used.
  • NearestThe nearest available value to the percentile will be used. In this case, the output pixel type will be the same as that of the input raster.
  • LinearThe weighted average of the two surrounding values from the percentile will be used. In this case, the output pixel type will be floating point.
String
Circular Wrap Value
(Optional)

The value that will be used to convert a linear value to the range of a given circular mean. Its value must be positive. The default value is 360 degrees.

This parameter is only supported if the Statistics Type parameter is set to Circular Mean.

Double

Derived Output

LabelExplanationData Type
Raster Function Arguments JSON

The arguments of the function. This output is for internal use only.

String

Return Value

LabelExplanationData Type
Output Multidimensional Raster

The output raster can only be a multidimensional raster in Cloud Raster Format (.crf file).

Raster

DimensionalMovingStatistics(in_raster, {dimension}, {backward_window}, {forward_window}, {nodata_handling}, {statistics_type}, {percentile_value}, {percentile_interpolation_type}, {circular_wrap_value})
NameExplanationData Type
in_raster

The input raster can only be a multidimensional raster in Cloud Raster Format (.crf file).

Raster Layer
dimension
(Optional)

The name of the dimension along which the window will move.

The default value is the first dimension other than x,y found in the input multidimensional raster.

String
backward_window
(Optional)

The value of how many slices before or above to be included in the defined window. The value must be a positive integer from 1 to 100. The default value is 1.

The unit of this parameter is slice.

Long
forward_window
(Optional)

The value of how many slices after or below to be included in the defined window. The value must be a positive integer from 1 to 100. The default value is 1.

The unit of this parameter is slice.

Long
nodata_handling
(Optional)

Specifies how NoData values will be handled by the statistic calculation.

  • DATANoData values in the value input will be ignored in the results of the defined window that they fall within. This is the default.
  • NODATAOutput values will be NoData if any NoData values are found in the input within the defined window.
  • FILL_NODATANoData cell values will be replaced using the selected statistic on the values within the defined window.
String
statistics_type
(Optional)

Specifies the statistic type to be calculated.

  • MEANThe mean (average value) of the cells in the defined window will be calculated. This is the default.
  • CIRCULAR_MEANThe mean for angles or other cyclic quantities—such as compass direction in degrees, daytimes, or fractional parts of real numbers—will be calculated. When this statistics type is selected, use the circular_wrap_value parameter to designate a wrap value.
  • MAJORITYThe majority (value that occurs most often) of the cells in the defined window will be identified.
  • MAXIMUMThe maximum (largest value) of the cells in the defined window will be identified.
  • MEDIANThe median of the cells in the defined window will be identified.
  • MINIMUMThe minimum (smallest value) of the cells in the defined window will be identified.
  • PERCENTILEA percentile of the cells in the defined window will be calculated. The 90th percentile is calculated by default. When this statistics type is selected, use the percentile_value and percentile_interpolation_type parameters to designate the percentile to calculate and choose the interpolation type to use, respectively.
String
percentile_value
(Optional)

The percentile value that will be calculated. The default is 90, for the 90th percentile.

The value can range from 0 to 100. The 0th percentile is essentially equivalent to the minimum statistic, and the 100th percentile is equivalent to the maximum statistic. A value of 50 will produce essentially the same result as the median statistic.

This parameter is only supported if the statistics_type parameter is set to PERCENTILE. If any other statistic type is specified, this parameter will be ignored.

Double
percentile_interpolation_type
(Optional)

Specifies the method of interpolation that will be used when the percentile value falls between two cell values.

This parameter is only supported if the statistics_type parameter is set to MEDIAN or PERCENTILE. If any other statistic type is specified, this parameter will be ignored.

  • AUTO_DETECTIf the input raster is of integer pixel type, the NEAREST method will be used. If the input raster is of float pixel type, the LINEAR method will be used.
  • NEARESTThe nearest available value to the percentile will be used. In this case, the output pixel type will be the same as that of the input raster.
  • LINEARThe weighted average of the two surrounding values from the percentile will be used. In this case, the output pixel type will be floating point.
String
circular_wrap_value
(Optional)

The value that will be used to convert a linear value to the range of a given circular mean. Its value must be positive. The default value is 360 degrees.

This parameter is only supported if the statistics_type parameter is set to CIRCULAR_MEAN. If any other statistic type is specified, this parameter will be ignored.

Double

Return Value

NameExplanationData Type
out_raster

The output raster can only be a multidimensional raster in Cloud Raster Format (.crf file).

Raster

Derived Output

NameExplanationData Type
raster_function_arguments_json

The arguments of the function. This output is for internal use only.

String

Code sample

DimensionalMovingStatistics example 1 (Python window)

This example calculates the mean value in a three-slice window around each cell in the input multidimensional raster.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
out_dimstats = DimensionalMovingStatistics("md_raster.crf", "StdTime", 
                                           1, 1, "NODATA", "MEAN")
out_dimstats.save("C:/sapyexamples/output/DMS01.crf")
DimensionalMovingStatistics example 2 (stand-alone script)

This example determines the most frequently occurring value in a five-slice moving window around each cell in the input multidimensional raster.

# Name: DimensionalMovingStatistics_standalone.py
# Description: Calculates majority on a multidimensional raster 
#                along its time dimension.
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

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

# Set the analysis environment
env.workspace = "C:/sapyexamples/data"

# Set local variables
in_raster = "mining_location.crf"
dimension = "StdTime"
backward_window = 2
forward_window = 2
nodata_handling = "FILL_NODATA"
statistics_type = "MAJORITY"

# Execute DimensionalMovingStatistics
out_dimstats = DimensionalMovingStatistics(in_raster, dimension, 
                 backward_window, forward_window, nodata_handling, 
                 statistics_type)

# Save the output
out_dimstats.save("C:/sapyexamples/output/mining_location_out.crf")

Licensing information

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

Related topics