@OperatorMetadata(alias="BandMaths", category="Raster", version="1.1", copyright="(c) 2013 by Brockmann Consult", authors="Marco Zuehlke, Norman Fomferra, Marco Peters", description="Create a product with one or more bands using mathematical expressions.") public class BandMathsOp extends Operator
This band maths operator can be used to create a product with multiple bands based on mathematical expression.
All products specified as source must have the same width and height, otherwise the operator will fail.
The geo-coding information and metadata for the target product is taken from the first source product.
To reference a band of one of the source products within an expression use the following syntax:
$sourceProduct.#.bandName
Where # means the index of the source product. The index is zero based.
The bands of the first source product ($sourceProduct.0
) can be referenced without this
product identifier. The band name is sufficient.
When using this operator from the command-line Graph XML file must be provided in order to
specify all parameters. Here is some sample XML of how to use a BandMaths
node within
a graph:
<node id="bandMathsNode"> <operator>BandMaths</operator> <sources> <sourceProducts>readNode</sourceProducts> </sources> <parameters> <targetBands> <targetBand> <name>reflec_13</name> <expression>radiance_13 / (PI * SOLAR_FLUX_13)</expression> <description>TOA reflectance in channel 13</description> <type>float</type> <validExpression>reflec_13 >= 0</validExpression> <noDataValue>-999</noDataValue> <spectralBandIndex>13</spectralBandIndex> </targetBand> <targetBand> <name>reflec_14</name> <expression>radiance_14 / (PI * SOLAR_FLUX_14)</expression> <description>TOA reflectance in channel 14</description> <type>float</type> <validExpression>reflec_14 >= 0</validExpression> <noDataValue>-999</noDataValue> <spectralBandIndex>14</spectralBandIndex> </targetBand> </targetBands> <variables> <variable> <name>SOLAR_FLUX_13</name> <type>float</type> <value>914.18945</value> </variable> <variable> <name>SOLAR_FLUX_14</name> <type>float</type> <value>882.8275</value> </variable> <variable> <name>PI</name> <type>double</type> <value>3.1415</value> </variable> </variables> </parameters> </node>
Changes from version 1.0 to 1.1:
Modifier and Type | Class and Description |
---|---|
static class |
BandMathsOp.BandDescriptor
Describes a target band to be generated by this operator.
|
static class |
BandMathsOp.Spi |
static class |
BandMathsOp.Variable
Defines a variable which can be referred in
BandMathsOp.BandDescriptor.expression . |
Constructor and Description |
---|
BandMathsOp() |
Modifier and Type | Method and Description |
---|---|
void |
computeTile(Band band,
Tile targetTile,
ProgressMonitor pm)
Called by the framework in order to compute a tile for the given target band.
|
BandMathsOp.BandDescriptor[] |
getTargetBandDescriptors() |
BandMathsOp.Variable[] |
getVariables() |
void |
initialize()
Initializes this operator and sets the one and only target product.
|
void |
setTargetBandDescriptors(BandMathsOp.BandDescriptor... targetBandDescriptors) |
void |
setVariables(BandMathsOp.Variable... variables) |
canComputeTile, canComputeTileStack, checkForCancellation, computeTileStack, deactivateComputeTileMethod, dispose, doExecute, ensureSceneGeoCoding, ensureSingleRasterSize, ensureSingleRasterSize, execute, finalize, getId, getLogger, getParameter, getParameter, getProductManager, getSourceProduct, getSourceProduct, getSourceProductId, getSourceProducts, getSourceTile, getSourceTile, getSpi, getTargetProduct, getTargetProperty, setLogger, setParameter, setParameterDefaultValues, setRequiresAllBands, setSourceProduct, setSourceProduct, setSourceProducts, setSpi, setTargetProduct, stopTileComputationObservation, update
public BandMathsOp.BandDescriptor[] getTargetBandDescriptors()
public void setTargetBandDescriptors(BandMathsOp.BandDescriptor... targetBandDescriptors)
public BandMathsOp.Variable[] getVariables()
public void setVariables(BandMathsOp.Variable... variables)
public void initialize() throws OperatorException
Operator
The target product can be either defined by a field of type Product
annotated with the
TargetProduct
annotation or
by calling Operator.setTargetProduct(org.esa.snap.core.datamodel.Product)
method.
This method shall never be called directly. The framework calls this method after it has created
an instance of this Operator
. This will occur
only once durting the lifetime of an Operator
instance.
If not already done, calling the Operator.getTargetProduct()
will always trigger
a call to the initialize()
method.
Any client code that must be performed before computation of tile data
should be placed here.
initialize
in class Operator
OperatorException
- If an error occurs during operator initialisation.Operator.getTargetProduct()
public void computeTile(Band band, Tile targetTile, ProgressMonitor pm) throws OperatorException
Operator
The default implementation throws a runtime exception with the message "not implemented".
This method shall never be called directly.
computeTile
in class Operator
band
- The target band.targetTile
- The current tile associated with the target band to be computed.pm
- A progress monitor which should be used to determine computation cancellation requests.OperatorException
- If an error occurs during computation of the target raster.Copyright © 2014–2017 European Space Agency (ESA). All rights reserved.