Aggregate

获得 Image Analyst 许可后可用。

摘要

通过基于维度间隔和聚合方法组合输入多维栅格中的剖切来创建栅格对象。

说明

使用 Aggregate 函数可根据给定变量聚合多维栅格中的变量值。 例如,如果您拥有每日降水量数据,则可以确定月平均降水量值。

此函数可创建一个栅格对象,该栅格对象为输入多维栅格的聚合。 默认情况下,系统将计算与给定维度关联的所有变量的聚合。 例如,如果降水量、温度和风速都具有时间维度,在将 dimension_name 设置为时间维度的情况下,系统将分别聚合所有三个变量。 如果您只想聚合一个变量,请使用 Subset 函数,然后使用 Aggregate

栅格对象所引用的栅格数据集是临时性的。 要使其变为永久性数据集,请调用栅格对象的 save 方法。

语法

Aggregate (in_raster, dimension_name, raster_function, {raster_function_arguments}, {aggregation_definition}, {dimensionless})
参数说明数据类型
in_raster

The input multidimensional raster to be aggregated.

Raster
dimension_name

The aggregation dimension. This is the dimension along which the variables will be aggregated.

String
raster_function

The name of a raster function as a string or the path to a custom raster function (.rft.xml file) that will be used to compute the aggregated pixel values.

The following are the supported raster functions as strings:

  • Majority—The pixel value that occurs most frequently will be calculated across all slices in the interval, and NoData will be returned if there are any NoData pixels along the dimension.
  • MajorityContinueOnNoData—The pixel value that occurs most frequently will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • Max—The maximum value of a pixel will be calculated across all slices in the interval, and NoData will be returned if there are any NoData pixels along the dimension.
  • MaxContinueOnNoData—The maximum value of a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • Mean—The mean of a pixel will be calculated across all slices in the interval, and NoData will be returned if there are any NoData pixels along the dimension.
  • MeanContinueOnNoData—The mean of a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • Med—The median of a pixel will be calculated across all slices in the interval, and NoData will be returned if there are any NoData pixels along the dimension.
  • MedContinueOnNoData—The median of a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • Min—The minimum of a pixel will be calculated across all slices in the interval, and NoData will be returned if there are any NoData pixels along the dimension.
  • MinContinueOnNoData—The minimum of a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • Minority—The pixel value that occurs least frequently will be calculated across all slices in the interval, and NoData will be returned if there are any NoData pixels along the dimension.
  • MinorityContinueOnNoData—The pixel value that occurs least frequently will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • Percentile—The percentile of values for a pixel will be calculated across all slices in the interval, and NoData will be returned if there are any NoData pixels along the dimension.
  • PercentileContinueOnNoData—The percentile of values for a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • Range—The range of values for a pixel will be calculated across all slices in the interval, and NoData will be returned if there are any NoData pixels along the dimension.
  • RangeContinueOnNoData—The range of values for a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • Std—The standard deviation of a pixel will be calculated across all slices in the interval, and NoData will be returned if there are any NoData pixels along the dimension.
  • StdContinueOnNoData—The standard deviation of a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • Sum—The sum of a pixel's values will be calculated across all slices in the interval, and NoData will be returned if there are any NoData pixels along the dimension.
  • SumContinueOnNoData—The sum of a pixel's values will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • Variety—The number of unique pixel values will be calculated across all slices in the interval, and NoData will be returned if there are any NoData pixels along the dimension.
  • VarietyContinueOnNoData—The number of unique pixel values will be calculated across all slices in the interval, and NoData pixels will be ignored.

String
raster_function_arguments

The parameters and values associated with the raster function or function chain. If not specified, default values will be used.

(默认值为 None)

Dictionary
aggregation_definition

The dimension interval for which the data will be aggregated. The key-value pairs must follow one of the following formats:

  • 'interval':<interval_keyword>

    Use the interval keyword only when dimension_name is a time dimension. Interval keywords include HOURLY, DAILY, WEEKLY, MONTHLY, QUARTERLY, and YEARLY. For example, use this option to aggregate daily temperature data into monthly temperature data for each year. The output will include no more than 12 slices for each year.

  • 'recurrent_interval':<recurrent_interval_keyword>

    Use the recurrent interval keyword only when dimension_name is a time dimension. Recurrent interval keywords include DAILY, WEEKLY, MONTHLY, and QUARTERLY. For example, use this option to calculate the average temperature value for each month across all the years in the dataset. The output will include no more than 12 slices (one slice for each month of the year).

  • 'interval_value':<value>, 'interval_unit':<unit>

    Use the interval value to define recurring intervals. The interval unit is required when dimension_name is a time dimension. Interval unit keywords include HOUR, DAY, WEEK, MONTH, QUARTER, and YEAR. For example, use this option to aggregate daily temperature into temperature every 10 days.

  • 'interval_ranges':[(min, max),(min, max), ...]

    Use the interval ranges option to define custom intervals for aggregation. For example, use this option to aggregate daily temperature into temperature across specific seasonal dates.

If not specified, all slices across the dimension will be aggregated.

(默认值为 None)

Dictionary
dimensionless

Specifies whether the output will be a dimensionless raster. This is only possible when the output has a single slice.

  • True—The layer will not have dimension values.
  • False—The layer will have dimension values.

(默认值为 False)

Boolean
返回值
数据类型说明
Raster

输出聚合多维栅格。

代码示例

聚合示例

通过计算总体平均值、月平均值、10 天中的最小值以及 2 个范围中的最大值来聚合降水量数据。

import arcpy
from arcpy.ia import *

arcpy.CheckOutExtension("ImageAnalyst")

in_raster = Raster('ClimateData_Daily.nc', True)

# Choose the precipitation variable
prcp_raster = Subset(in_raster, variables = 'prcp')

# Calculate the average precipitation across the whole time period
avg_prcp = Aggregate(prcp_raster, 'StdTime', 'Mean')

# Calculate the monthly mean precipitation 
monthly_avg_prcp = Aggregate(prcp_raster, 'StdTime', 
	'Mean', {'interval': 'monthly'})

# Calculate the minimum precipitation every 10 days
min_precip_10day = Aggregate(prcp_raster, 'StdTime', 'Min', 
	{'interval_value' : 10, 'interval_unit': 'day'})

# Calculate the maximum precipitation in two separate time ranges
max_prcp_range = Aggregate(prcp_raster, 'StdTime', 'Max', 
	{'interval_ranges':  [('2001-01-01T00:00:00', '2001-02-01T00:00:00'), 
	('2001-12-01T00:00:00', '2001-12-24T00:00:00')]})