Aggregate

Доступно с лицензией Image Analyst.

Краткая информация

Создает растровый объект путем комбинирования срезов входного многомерного растра на основе интервала измерений и метода агрегации.

Обсуждение

Используйте функцию Aggregate для агрегирования значений переменной многомерного растра по заданной переменной. Например, если у вас есть данные о ежедневных осадках, вы можете определить среднемесячное количество осадков.

Эта функция создает растровый объект, который является агрегацией входного многомерного растра. По умолчанию агрегация вычисляется для всех переменных, связанных с данным измерением. Например, в случае, когда осадки, температура и скорость ветра имеют измерение времени, все три переменные будут агрегированы отдельно, если dimension_name задано как измерение времени. Если вы хотите агрегировать только одну переменную, используйте функцию Subset перед использованием Aggregate.

Указанный набор растровых данных является временным для растрового объекта. Чтобы сделать его постоянным, вы можете вызвать метод растрового объекта save.

Синтаксис

Aggregate (in_raster, dimension_name, {PercentileContinueOnNoData}, raster_function, {raster_function_arguments}, {aggregation_definition})
ПараметрОписаниеТип данных
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
PercentileContinueOnNoData

NoData will be ignored.

String
raster_function

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

Supported raster functions as strings include the following:

  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • MajorityContinueOnNoData—The pixel value that occurred most frequently will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • MaxContinueOnNoData—The maximum value of a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • MeanContinueOnNoData—The mean of a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • MedContinueOnNoData—The median of a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • MinContinueOnNoData—The minimum of a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • MinorityContinueOnNoData—The pixel value that occurs least frequently will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • RangeContinueOnNoData—The range of values for a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • StdContinueOnNoData—The standard deviation of a pixel will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • SumContinueOnNoData—The sum of a pixel's values will be calculated across all slices in the interval, and NoData pixels will be ignored.
  • 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.

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.

Dictionary
Возвращаемое значение
Тип данныхОписание
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')]})