Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bandwise expression #58

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading