@OperatorMetadata(alias="Write", category="Input-Output", version="1.3", authors="Marco Zuehlke, Norman Fomferra", copyright="(c) 2010 by Brockmann Consult", description="Writes a data product to a file.", autoWriteDisabled=true) public class WriteOp extends Operator
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);
Modifier and Type | Class and Description |
---|---|
static class |
WriteOp.Spi |
Constructor and Description |
---|
WriteOp() |
WriteOp(Product sourceProduct,
File file,
String formatName) |
Modifier and Type | Method and Description |
---|---|
boolean |
canComputeTile()
Determines whether this operator's
computeTileStack method can be used. |
boolean |
canComputeTileStack()
Determines whether this operator's
computeTileStack method can be used. |
void |
computeTile(Band targetBand,
Tile targetTile,
ProgressMonitor pm)
Called by the framework in order to compute a tile for the given target band.
|
void |
computeTileStack(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.
|
void |
dispose()
Releases the resources the operator has acquired during its lifetime.
|
void |
doExecute(ProgressMonitor pm)
Executes the operator.
|
File |
getFile() |
String |
getFormatName() |
void |
initialize()
Initializes this operator and sets the one and only target product.
|
boolean |
isClearCacheAfterRowWrite() |
boolean |
isDeleteOutputOnFailure() |
boolean |
isWriteEntireTileRows() |
void |
setClearCacheAfterRowWrite(boolean clearCacheAfterRowWrite) |
void |
setDeleteOutputOnFailure(boolean deleteOutputOnFailure) |
void |
setFile(File file) |
void |
setFormatName(String formatName) |
void |
setIncremental(boolean incremental) |
void |
setWriteEntireTileRows(boolean writeEntireTileRows) |
void |
writeProduct(ProgressMonitor pm)
Writes the source product.
|
checkForCancellation, deactivateComputeTileMethod, 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 File getFile()
public void setFile(File file)
public String getFormatName()
public void setIncremental(boolean incremental)
public void setFormatName(String formatName)
public boolean isDeleteOutputOnFailure()
public void setDeleteOutputOnFailure(boolean deleteOutputOnFailure)
public boolean isWriteEntireTileRows()
public void setWriteEntireTileRows(boolean writeEntireTileRows)
public boolean isClearCacheAfterRowWrite()
public void setClearCacheAfterRowWrite(boolean clearCacheAfterRowWrite)
public boolean canComputeTile()
Operator
computeTileStack
method can be used.
The default implementation of this method checks if the this operator's class
overrides the Operator.computeTileStack
method.
canComputeTile
in class Operator
true
if so.public boolean canComputeTileStack()
Operator
computeTileStack
method can be used.
The default implementation of this method checks if the this operator's class
overrides the Operator.computeTileStack
method.
canComputeTileStack
in class Operator
true
if so.public void writeProduct(ProgressMonitor pm)
pm
- A progress monitor.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 doExecute(ProgressMonitor pm)
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
Operator.execute(ProgressMonitor)
.The default implementation only progresses the progress monitor.
public void computeTile(Band targetBand, 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
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.OperatorException
- If an error occurs during computation of the target raster.public void computeTileStack(Map<Band,Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm) throws OperatorException
Operator
The default implementation throws a runtime exception with the message "not implemented".
This method shall never be called directly.
computeTileStack
in class Operator
targetTiles
- The current tiles to be computed for each target band.targetRectangle
- The area in pixel coordinates to be computed (same for all rasters in targetRasters
).pm
- A progress monitor which should be used to determine computation cancellation requests.OperatorException
- If an error occurs during computation of the target rasters.Copyright © 2014–2022 European Space Agency (ESA). All rights reserved.