diff --git a/src/SUMMARY.md b/src/SUMMARY.md index e61b48e..0a51272 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -33,6 +33,7 @@ - [Operators](./operators/intro.md) + - [BandNeighborhoodAggregate](./operators/band-neighborhood-aggregate.md) - [BandwiseExpression](./operators/bandwise-expression.md) - [ColumnRangeFilter](./operators/columnrangefilter.md) - [Expression](./operators/expression.md) diff --git a/src/operators/band-neighborhood-aggregate.md b/src/operators/band-neighborhood-aggregate.md new file mode 100644 index 0000000..794bb7e --- /dev/null +++ b/src/operators/band-neighborhood-aggregate.md @@ -0,0 +1,127 @@ +# Band Neighborhood Agrgegate + +The `BandNeighborhoodAggregate` operator performs a pixel-wise aggregate function over the neighboring bands. +The output is a raster time-series with the same number of bands as the input raster. +The pixel values are replaced by the result of the aggregate function. +This allows e.g. the computation of a moving average over the bands of a raster time-series. + +## Parameters + +| Parameter | Type | Description | Example Value | +| ----------- | ----------------------- | ------------------ | -------------------------------------- | +| `aggregate` | `NeighborhoodAggregate` | The aggrate method | `{"type": "average", "windowSize": 3}` | + +## Types + +The following describes the types used in the parameters. + +### NeighborhoodAggregate + +There are several types of neighborhood aggregate functions. + +#### Average + +This aggregate function computes the average of the neighboring bands. +The `windowSize` parameter defines the number of bands to consider for the average and must be an odd number. +For the borders, the window is reduced to the available bands. + +##### Example + +```json +{ + "type": "average", + "windowSize": 3 +} +``` + +#### FirstDerivative + +This aggregate function computes and approximation of the first derivative of the neighboring bands using the central difference method. +Given the bands \\( x_i \\) and the pixel value \\( y_i \\) the derivative is computed as + +\\[ f′(x_i​) \approx \frac{​y_{i+1} ​ − y_{i−1​​}}{x_{i+1}​ − x_{i−1}} \\] + +and forward/backward difference for the endpoints + +\\[ f′(x_1​) \approx \frac{y_2 - y_1}{x_2 - x_1} \\] + +\\[ f′(x_n​) \approx \frac{y_n - y_{n-1}}{x_n - x_{n-1}} \\] + + +To compute the distance \\( x_{i+1}​ − x_{i−1} \\), a `bandDistance` parameter is required. + +##### BandDistance + +The `bandDistance` parameter defines the distance between the bands. +Currently, the band distance is assumed to be constant and can be specified in the following way: + +```json +{ + "type": "equallySpaced", + "distance": 1.0 +} +``` + +#### Example + +```json +{ + "type": "firstDerivative", + "bandDistance": { + "type": "equallySpaced", + "distance": 1.0 + } +} +``` + +## Inputs + +The `BandNeighborhoodAggregate` operator expects a single raster input . + +| Parameter | Type | +| --------- | -------------------- | +| `source` | `SingleRasterSource` | + +## Errors + +The operation fails if there are not enough bands in the input raster to compute the aggregate function or the number of bands does not match the requirements of the aggregate function. + +## Example JSON + +```json +{ + "type": "BandNeighborhoodAggregate", + "params": { + "type": "average", + "windowSize": 3 + }, + "sources": { + "raster": { + "type": "RasterStacker", + "params": {}, + "sources": { + "rasters": [ + { + "type": "GdalSource", + "params": { + "data": "sentinel2-b8" + } + }, + { + "type": "GdalSource", + "params": { + "data": "sentinel2-b4" + } + }, + { + "type": "GdalSource", + "params": { + "data": "sentinel2-b2" + } + } + ] + } + } + } +} +``` diff --git a/src/operators/band-neighborhood.md b/src/operators/band-neighborhood.md new file mode 100644 index 0000000..ffdfdee --- /dev/null +++ b/src/operators/band-neighborhood.md @@ -0,0 +1 @@ +# BandNeighborhood