# TemporalRasterAggregation

The TemporalRasterAggregation aggregates a raster time series into uniform time intervals (windows). The output is a time series that begins with the first window that contains the start of the query time. Each time slice has the same length, defined by the window parameter. The pixel values are computed by aggregating all rasters that are contained in the input and that are valid in the current window using the defined aggregation method. All output slices that are contained in the query time interval are produced by the operator. The optional windowReference parameter allows specifying a custom anchor point for the windows. This is the imagined start from which on the timeline is divided into uniform aggregation windows. By default, it is 1970-01-01T00:00:00Z which means that windows of, e.g., 1 hour or 1 month will begin at the full hour or the start of the month.

An example usage scenario is to transform a daily raster time series into monthly aggregates. Here, the query should start at the beginning of the month and the window should be 1 month. The aggregation method allows calculating, e.g., the maximum or mean value for each pixel. If we perform a query with time [2021-01-01, 2021-04-01), we would get a time series with three time steps. If we perform a query with an instant like [2021-01-01, 2021-01-01), we will get a single time step containing the aggregated values for January 2021.

## Parameters

ParameterTypeDescriptionExample Value
aggregationAggregationmethod for aggregating pixels
{  "type": "max",  "ignoreNoData": false}
windowTimeSteplength of time steps
{  "granularity": "Months",  "step": 1}
windowReferenceTimeInstance(Optional) anchor point for the aggregation windows. Default value is 1970-01-01T00:00:00Z1970-01-01T00:00:00Z
outputTypeRasterDataType(Optional) A raster data type for the output. Same as input, if not specified.
U8

## Types

The following describes the types used in the parameters.

### Aggregation

There are different methods that can be used to aggregate the raster time series. Encountering a no data value makes the aggregation value of a pixel also no data unless the ignoreNoData parameter is set to true.

VariantParametersDescription
minignoreNoData: boolminimum value
maxignoreNoData: boolmaximum value
firstignoreNoData: boolfirst encountered value
lastignoreNoData: boollast encountered value
meanignoreNoData: boolmean value
sumignoreNoData: boolsum of the values
countignoreNoData: boolcount the number of values

Attention: For the variants sum and count, a saturating addition is used. This means, that if the sum of two values exceeds the maximum value of the data type, the result will be the maximum value of the data type. Thus, users must be aware to choose a data type that is large enough to hold the result of the aggregation.

## Inputs

The TemporalRasterAggregation operator expects exactly one raster input.

ParameterType
rasterSingleRasterSource

## Errors

If the aggregation method is first, last, or mean and the input raster has no no data value, an error is thrown.

## Example JSON

{
"type": "TemporalRasterAggregation",
"params": {
"aggregation": {
"type": "max",
"ignoreNoData": false
},
"window": {
"granularity": "Months",
"step": 1
},
"windowReference": "1970-01-01T00:00:00Z",
"sources": {
"raster": {
"type": "GdalSource",
"params": {
"data": {
"type": "internal",
"datasetId": "a626c880-1c41-489b-9e19-9596d129859c"
}
}
}
}
}
}