Class WriteOp
It is used by the framework, e.g. the gpt command line tool, to write target products.
It may also be used by clients to write out break-point product files. This is done by placing
a WriteOp node after any node in a processing graph:
<node id="anyNodeId">
<operator>Write</operator>
<sources>
<source>${anySourceNodeId}</source>
</sources>
<parameters>
<file>/home/norman/eo-data/output/test.nc</file>
<formatName>NetCDF</formatName>
<deleteOutputOnFailure>true</deleteOutputOnFailure>
<writeEntireTileRows>true</writeEntireTileRows>
<clearCacheAfterRowWrite>true</clearCacheAfterRowWrite>
</parameters>
</node>
Clients may also use this operator in a programmatic way:
WriteOp writeOp = new WriteOp(sourceProduct, file, formatName); writeOp.setDeleteOutputOnFailure(true); writeOp.setWriteEntireTileRows(true); writeOp.writeProduct(progressMonitor);
- Since:
- BEAM 4.2
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines whether this operator'scomputeTileStackmethod can be used.booleanDetermines whether this operator'scomputeTileStackmethod can be used.voidcomputeTile(Band targetBand, Tile targetTile, ProgressMonitor pm) Called by the framework in order to compute a tile for the given target band.voidcomputeTileStack(Map<Band, Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm) Called by the framework in order to compute the stack of tiles for the given target bands.voiddispose()Releases the resources the operator has acquired during its lifetime.voidExecutes the operator.getFile()voidInitializes this operator and sets the one and only target product.booleanbooleanbooleanvoidsetClearCacheAfterRowWrite(boolean clearCacheAfterRowWrite) voidsetDeleteOutputOnFailure(boolean deleteOutputOnFailure) voidvoidsetFormatName(String formatName) voidsetIncremental(boolean incremental) voidsetWriteEntireTileRows(boolean writeEntireTileRows) voidWrites the source product.Methods inherited from class org.esa.snap.core.gpf.Operator
checkForCancellation, 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
-
Constructor Details
-
WriteOp
public WriteOp() -
WriteOp
-
-
Method Details
-
getFile
-
setFile
-
getFormatName
-
setIncremental
public void setIncremental(boolean incremental) -
setFormatName
-
isDeleteOutputOnFailure
public boolean isDeleteOutputOnFailure() -
setDeleteOutputOnFailure
public void setDeleteOutputOnFailure(boolean deleteOutputOnFailure) -
isWriteEntireTileRows
public boolean isWriteEntireTileRows() -
setWriteEntireTileRows
public void setWriteEntireTileRows(boolean writeEntireTileRows) -
isClearCacheAfterRowWrite
public boolean isClearCacheAfterRowWrite() -
setClearCacheAfterRowWrite
public void setClearCacheAfterRowWrite(boolean clearCacheAfterRowWrite) -
canComputeTile
public boolean canComputeTile()Description copied from class:OperatorDetermines whether this operator'scomputeTileStackmethod can be used.The default implementation of this method checks if the this operator's class overrides the
Operator.computeTileStackmethod.- Overrides:
canComputeTilein classOperator- Returns:
trueif so.
-
canComputeTileStack
public boolean canComputeTileStack()Description copied from class:OperatorDetermines whether this operator'scomputeTileStackmethod can be used.The default implementation of this method checks if the this operator's class overrides the
Operator.computeTileStackmethod.- Overrides:
canComputeTileStackin classOperator- Returns:
trueif so.
-
writeProduct
Writes the source product.- Parameters:
pm- A progress monitor.
-
initialize
Description copied from class:OperatorInitializes this operator and sets the one and only target product.The target product can be either defined by a field of type
Productannotated with theTargetProductannotation or by callingOperator.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 anOperatorinstance. If not already done, calling theOperator.getTargetProduct()will always trigger a call to theinitialize()method.Any client code that must be performed before computation of tile data should be placed here.
- Specified by:
initializein classOperator- Throws:
OperatorException- If an error occurs during operator initialisation.- See Also:
-
doExecute
Description copied from class:OperatorExecutes the operator.For operators that compute raster data tiles, the method is usually a no-op. Other operators might perform their main work in this method, e.g. perform some image analysis such as extracting statistics and other features from data products.
Don't call this method directly. The framework may call this method
- once before the very first tile is computed, or
- as a result of a call to
Operator.execute(ProgressMonitor).
The default implementation only progresses the progress monitor.
-
computeTile
public void computeTile(Band targetBand, Tile targetTile, ProgressMonitor pm) throws OperatorException Description copied from class:OperatorCalled by the framework in order to compute a tile for the given target band.The default implementation throws a runtime exception with the message "not implemented".
This method shall never be called directly.
- Overrides:
computeTilein classOperator- Parameters:
targetBand- 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.- Throws:
OperatorException- If an error occurs during computation of the target raster.
-
computeTileStack
public void computeTileStack(Map<Band, Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm) throws OperatorExceptionDescription copied from class:OperatorCalled by the framework in order to compute the stack of tiles for the given target bands.The default implementation throws a runtime exception with the message "not implemented".
This method shall never be called directly.
- Overrides:
computeTileStackin classOperator- Parameters:
targetTiles- The current tiles to be computed for each target band.targetRectangle- The area in pixel coordinates to be computed (same for all rasters intargetRasters).pm- A progress monitor which should be used to determine computation cancellation requests.- Throws:
OperatorException- If an error occurs during computation of the target rasters.
-
dispose
public void dispose()Description copied from class:OperatorReleases the resources the operator has acquired during its lifetime. The default implementation does nothing.Overrides should make sure to call
super.dispose()as well.
-