Skip to content

Commit

Permalink
Merge pull request #58 from geo-engine/bandwise-expression
Browse files Browse the repository at this point in the history
bandwise expression
  • Loading branch information
jdroenner authored Jun 17, 2024
2 parents a7390f2 + 36c49db commit c51e521
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

- [Operators](./operators/intro.md)

- [BandwiseExpression](./operators/bandwise-expression.md)
- [ColumnRangeFilter](./operators/columnrangefilter.md)
- [Expression](./operators/expression.md)
- [GdalSource](./operators/gdalsource.md)
Expand Down
61 changes: 61 additions & 0 deletions src/operators/bandwise-expression.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Bandwise Raster Expression

The `BandwiseExpression` operator performs a pixel-wise mathematical expression on each band of a raster source.
For more details on the expression syntax, see the [Expression](/operators/expressions.md) operator.
Note, that in the `BandwiseExpression` operator, it is only possible to map one pixel value to another and not reference any other pixels or bands.
The variable name for the pixel value is `x`.

## Parameters

| Parameter | Type | Description | Example Value |
| ------------ | ------------------------------------------------ | ----------------------------------------------------------------------------------------------------------- | ------------------------------- |
| `expression` | `Expression` | Expression script | <pre><code>ln(1/x)</code></pre> |
| `outputType` | [`RasterDataType`](/datatypes/rasterdatatype.md) | A raster data type for the output | <pre><code>U8</code></pre> |
| `mapNoData` | `bool` | Should NO DATA values be mapped with the `expression`? Otherwise, they are mapped automatically to NO DATA. | <pre><code>false</code></pre> |

## Inputs

The `Expression` operator expects a single raster input .

| Parameter | Type |
| --------- | -------------------- |
| `source` | `SingleRasterSource` |

## Errors

The parsing of the expression can fail if there are, e.g., syntax errors.

## Example JSON

```json
{
"type": "BandwiseExpression",
"params": {
"expression": "ln(1/x)",
"outputType": "F32",
"mapNoData": false
},
"sources": {
"raster": {
"type": "RasterStacker",
"params": {},
"sources": {
"rasters": [
{
"type": "GdalSource",
"params": {
"data": "sentinel2-b8"
}
},
{
"type": "GdalSource",
"params": {
"data": "sentinel2-b4"
}
}
]
}
}
}
}
```
2 changes: 1 addition & 1 deletion src/operators/expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ However, the last expression must be without a semicolon.

## Inputs

The `Expression` operator expects one rater input with at most 8 bands.
The `Expression` operator expects one raster input with at most 8 bands.

| Parameter | Type |
| --------- | -------------------- |
Expand Down

0 comments on commit c51e521

Please sign in to comment.