-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from geo-engine/band-neighborhood
add band neighboorhood operator
- Loading branch information
Showing
3 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}} \\] | ||
|
||
<!-- prettier-ignore --> | ||
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" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# BandNeighborhood |