forked from OSGeo/gdal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VRT Pixel Functions: Add function to evaluate arbitrary expression (O…
…SGeo#11209) Adds a C++ pixel function called "expression" that can evaluate an arbitrary expression (or indeed, a mini-program) using either: - the [exprtk library](https://www.partow.net/programming/exprtk/index.html). This is a single MIT-licensed header, that appears to be quite widely used. But which causes a significant increase in size of libgdal (8 MB) - or [muparser](https://github.com/beltoforion/muparser), that supports a reasonable variety of functions including a ternary conditional operator muparser is the deault when the "dialect" is not specified. An example VRT that is allowed is: ``` <VRTDataset rasterXSize="1" rasterYSize="1"> <VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand"> <PixelFunctionType>expression</PixelFunctionType> <PixelFunctionArguments expression="(NIR-R)/(NIR+R)" /> <SimpleSource name="NIR"> <SourceFilename relativeToVRT="0">source_0.tif</SourceFilename> <SourceBand>1</SourceBand> </SimpleSource> <SimpleSource name="R"> <SourceFilename relativeToVRT="0">source_1.tif</SourceFilename> <SourceBand>1</SourceBand> </SimpleSource> </VRTRasterBand> </VRTDataset> ```
- Loading branch information
Showing
29 changed files
with
2,272 additions
and
223 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
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
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
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
14 changes: 14 additions & 0 deletions
14
autotest/gdrivers/data/vrt/arraysource_derived_expression.vrt
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,14 @@ | ||
<VRTDataset rasterXSize="20" rasterYSize="20"> | ||
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand"> | ||
<PixelFunctionType>expression</PixelFunctionType> | ||
<PixelFunctionArguments expression="B1 + 5" dialect="muparser"/> | ||
<ArraySource> | ||
<Array name="test"> | ||
<DataType>Float64</DataType> | ||
<Dimension name="Y" size="20"/> | ||
<Dimension name="X" size="20"/> | ||
<ConstantValue>10</ConstantValue> | ||
</Array> | ||
</ArraySource> | ||
</VRTRasterBand> | ||
</VRTDataset> |
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
Oops, something went wrong.