Package org.esa.snap.core.datamodel
Class AbstractBand
java.lang.Object
com.bc.ceres.core.ExtensibleObject
org.esa.snap.core.datamodel.ProductNode
org.esa.snap.core.datamodel.DataNode
org.esa.snap.core.datamodel.RasterDataNode
org.esa.snap.core.datamodel.AbstractBand
- All Implemented Interfaces:
 Extensible,Scaling,SceneTransformProvider
- Direct Known Subclasses:
 Band
The 
AbstractBand class provides a set of pixel access methods but does not provide an implementation of
 the actual reading and writing of pixel data from or into a raster.- 
Nested Class Summary
Nested classes/interfaces inherited from class org.esa.snap.core.datamodel.RasterDataNode
RasterDataNode.RasterDataProcessor - 
Field Summary
Fields inherited from class org.esa.snap.core.datamodel.RasterDataNode
INVALID_POS_TEXT, IO_ERROR_TEXT, NO_DATA_TEXT, PROPERTY_NAME_ANCILLARY_RELATIONS, PROPERTY_NAME_ANCILLARY_VARIABLES, PROPERTY_NAME_GEO_CODING, PROPERTY_NAME_IMAGE_INFO, PROPERTY_NAME_IMAGE_TO_MODEL_TRANSFORM, PROPERTY_NAME_LOG_10_SCALED, PROPERTY_NAME_MODEL_TO_SCENE_TRANSFORM, PROPERTY_NAME_NO_DATA_VALUE, PROPERTY_NAME_NO_DATA_VALUE_USED, PROPERTY_NAME_SCALING_FACTOR, PROPERTY_NAME_SCALING_OFFSET, PROPERTY_NAME_SCENE_TO_MODEL_TRANSFORM, PROPERTY_NAME_STX, PROPERTY_NAME_TIME_CODING, PROPERTY_NAME_VALID_PIXEL_EXPRESSIONFields inherited from class org.esa.snap.core.datamodel.DataNode
PROPERTY_NAME_DATA, PROPERTY_NAME_READ_ONLY, PROPERTY_NAME_SYNTHETIC, PROPERTY_NAME_UNITFields inherited from class org.esa.snap.core.datamodel.ProductNode
PROPERTY_NAME_DESCRIPTION, PROPERTY_NAME_NAME - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionprotected static double[]ensureMinLengthArray(double[] array, int length) protected static float[]ensureMinLengthArray(float[] array, int length) protected static int[]ensureMinLengthArray(int[] array, int length) voidEnsures that raster data existsdoublegetPixelDouble(int x, int y) Gets the sample for the pixel located at (x,y) as a double value.floatgetPixelFloat(int x, int y) Gets the sample for the pixel located at (x,y) as a float value.intgetPixelInt(int x, int y) Gets the sample for the pixel located at (x,y) as an integer value.double[]getPixels(int x, int y, int w, int h, double[] pixels, ProgressMonitor pm) Retrieves the range of pixels specified by the coordinates as double array.float[]getPixels(int x, int y, int w, int h, float[] pixels, ProgressMonitor pm) Retrieves the range of pixels specified by the coordinates as float array.int[]getPixels(int x, int y, int w, int h, int[] pixels, ProgressMonitor pm) Retrieves the range of pixels specified by the coordinates as integer array.intintabstract longgetRawStorageSize(ProductSubsetDef subsetDef) Gets an estimated raw storage size in bytes of this product node.voidLoads the complete underlying raster data.double[]readPixels(int x, int y, int w, int h, double[] pixels, ProgressMonitor pm) Retrieves the band data at the given offset (x, y), width and height as double data.float[]readPixels(int x, int y, int w, int h, float[] pixels, ProgressMonitor pm) Retrieves the band data at the given offset (x, y), width and height as float data.int[]readPixels(int x, int y, int w, int h, int[] pixels, ProgressMonitor pm) Retrieves the band data at the given offset (x, y), width and height as integer data.voidsetPixelDouble(int x, int y, double pixelValue) Sets the pixel value at the given pixel coordinate to the given pixel value.voidsetPixelFloat(int x, int y, float pixelValue) Sets the pixel at the given pixel coordinate to the given pixel value.voidsetPixelInt(int x, int y, int pixelValue) Sets the pixel at the given pixel co-ordinate to the given pixel value.voidsetPixels(int x, int y, int w, int h, double[] pixels) Sets a range of pixels specified by the coordinates as double array.voidsetPixels(int x, int y, int w, int h, float[] pixels) Sets a range of pixels specified by the coordinates as float array.voidsetPixels(int x, int y, int w, int h, int[] pixels) Sets a range of pixels specified by the coordinates as integer array.voidUn-loads the raster data for this band.voidwritePixels(int x, int y, int w, int h, double[] pixels, ProgressMonitor pm) Retrieves the range of pixels specified by the coordinates as double array.voidwritePixels(int x, int y, int w, int h, float[] pixels, ProgressMonitor pm) Retrieves the range of pixels specified by the coordinates as float array.voidwritePixels(int x, int y, int w, int h, int[] pixels, ProgressMonitor pm) Retrieves the range of pixels specified by the coordinates as integer array.Methods inherited from class org.esa.snap.core.datamodel.RasterDataNode
acceptVisitor, addAncillaryVariable, canBeOrthorectified, checkCompatibleRasterData, clearNoDataValue, computeStxImpl, createColorIndexedImage, createCompatibleRasterData, createCompatibleRasterData, createCompatibleSceneRasterData, createDefaultImageInfo, createDefaultImageInfo, createMultiLevelModel, createPointing, createRgbImage, createSourceImage, createTransectProfileData, dispose, fireImageInfoChanged, getAncillaryRelations, getAncillaryVariable, getAncillaryVariables, getGeoCoding, getGeophysicalDataType, getGeophysicalImage, getGeophysicalNoDataValue, getImageInfo, getImageInfo, getImageInfo, getImageToModelTransform, getModelToSceneTransform, getMultiLevelModel, getNoDataValue, getOverlayMaskGroup, getPixels, getPixels, getPixelString, getPointing, getRasterData, getRasterSize, getSampleFloat, getSampleInt, getScalingFactor, getScalingOffset, getSceneToModelTransform, getSourceImage, getStx, getStx, getTimeCoding, getValidMaskExpression, getValidMaskImage, getValidPixelExpression, getValidShape, hasGeoCoding, hasIntPixels, hasRasterData, isCompatibleRasterData, isFloatingPointType, isGeophysicalImageSet, isLog10Scaled, isNoDataValueSet, isNoDataValueUsed, isPixelValid, isPixelValid, isPixelValid, isPixelWithinImageBounds, isScalingApplied, isSourceImageSet, isStxSet, isValidMaskImageSet, isValidMaskProperty, isValidMaskUsed, loadRasterData, processRasterData, quantizeRasterData, quantizeRasterData, readPixels, readPixels, readPixels, readRasterData, readRasterData, readRasterDataFully, readRasterDataFully, readValidMask, removeAncillaryVariable, removeCachedImageData, resetValidMask, scale, scaleInverse, setAncillaryRelations, setGeoCoding, setGeophysicalNoDataValue, setImageInfo, setImageInfo, setImageToModelTransform, setLog10Scaled, setModelToSceneTransform, setModified, setNoDataValue, setNoDataValueUsed, setRasterData, setScalingFactor, setScalingOffset, setSceneToModelTransform, setSourceImage, setSourceImage, setStx, setTimeCoding, setValidPixelExpression, updateExpression, writePixels, writePixels, writePixels, writeRasterData, writeRasterData, writeRasterDataFully, writeRasterDataFullyMethods inherited from class org.esa.snap.core.datamodel.DataNode
checkDataCompatibility, createCompatibleProductData, fireProductNodeDataChanged, getData, getDataElems, getDataElemSize, getDataType, getNumDataElems, getUnit, isReadOnly, isSynthetic, setData, setDataElems, setReadOnly, setSynthetic, setUnitMethods inherited from class org.esa.snap.core.datamodel.ProductNode
fireProductNodeChanged, fireProductNodeChanged, getDescription, getDisplayName, getName, getOwner, getProduct, getProductReader, getProductReaderSafe, getProductRefString, getProductSafe, getProductWriter, getProductWriterSafe, getRawStorageSize, isModified, isPartOfSubset, isValidNodeName, removeFromFile, setDescription, setName, setNodeName, setOwner, toStringMethods inherited from class com.bc.ceres.core.ExtensibleObject
getExtension 
- 
Constructor Details
- 
AbstractBand
 
 - 
 - 
Method Details
- 
getRasterWidth
public int getRasterWidth()- Specified by:
 getRasterWidthin classRasterDataNode- Returns:
 - The width of the raster in pixels.
 
 - 
getRasterHeight
public int getRasterHeight()- Specified by:
 getRasterHeightin classRasterDataNode- Returns:
 - The height of the raster in pixels.
 
 - 
writePixels
public void writePixels(int x, int y, int w, int h, int[] pixels, ProgressMonitor pm) throws IOException Retrieves the range of pixels specified by the coordinates as integer array. Reads the data from disk if ot is not in memory yet. If the data is loaded, just copies the data.- Specified by:
 writePixelsin classRasterDataNode- Parameters:
 x- x offset into the bandy- y offset into the bandw- width of the pixel array to be readh- height of the pixel array to be read.pixels- integer array to be filled with datapm- a monitor to inform the user about progress- Throws:
 IOException- if an I/O error occurs
 - 
writePixels
public void writePixels(int x, int y, int w, int h, float[] pixels, ProgressMonitor pm) throws IOException Retrieves the range of pixels specified by the coordinates as float array. Reads the data from disk if ot is not in memory yet. If the data is loaded, just copies the data.- Specified by:
 writePixelsin classRasterDataNode- Parameters:
 x- x offset into the bandy- y offset into the bandw- width of the pixel array to be readh- height of the pixel array to be read.pixels- float array to be filled with datapm- a monitor to inform the user about progress- Throws:
 IOException- if an I/O error occurs
 - 
writePixels
public void writePixels(int x, int y, int w, int h, double[] pixels, ProgressMonitor pm) throws IOException Retrieves the range of pixels specified by the coordinates as double array. Reads the data from disk if ot is not in memory yet. If the data is loaded, just copies the data.- Specified by:
 writePixelsin classRasterDataNode- Parameters:
 x- x offset into the bandy- y offset into the bandw- width of the pixel array to be readh- height of the pixel array to be read.pixels- double array to be filled with datapm- a monitor to inform the user about progress- Throws:
 IOException- if an I/O error occurs
 - 
getRawStorageSize
Gets an estimated raw storage size in bytes of this product node.- Overrides:
 getRawStorageSizein classDataNode- Parameters:
 subsetDef- if notnullthe subset may limit the size returned- Returns:
 - the size in bytes.
 
 - 
ensureMinLengthArray
protected static int[] ensureMinLengthArray(int[] array, int length)  - 
ensureMinLengthArray
protected static float[] ensureMinLengthArray(float[] array, int length)  - 
ensureMinLengthArray
protected static double[] ensureMinLengthArray(double[] array, int length)  - 
getPixelInt
public int getPixelInt(int x, int y) Gets the sample for the pixel located at (x,y) as an integer value.- Specified by:
 getPixelIntin classRasterDataNode- Parameters:
 x- The X co-ordinate of the pixel locationy- The Y co-ordinate of the pixel location- Returns:
 - the pixel value at (x,y)
 - Throws:
 NullPointerException- if this band has no raster dataArrayIndexOutOfBoundsException- if the co-ordinates are not in bounds
 - 
getPixelFloat
public float getPixelFloat(int x, int y) Gets the sample for the pixel located at (x,y) as a float value.- Specified by:
 getPixelFloatin classRasterDataNode- Parameters:
 x- The X co-ordinate of the pixel locationy- The Y co-ordinate of the pixel location- Returns:
 - the pixel value at (x,y)
 - Throws:
 NullPointerException- if this band has no raster dataArrayIndexOutOfBoundsException- if the co-ordinates are not in bounds
 - 
getPixelDouble
public double getPixelDouble(int x, int y) Gets the sample for the pixel located at (x,y) as a double value.- Specified by:
 getPixelDoublein classRasterDataNode- Parameters:
 x- The X co-ordinate of the pixel locationy- The Y co-ordinate of the pixel location- Returns:
 - the pixel value at (x,y)
 - Throws:
 NullPointerException- if this band has no raster dataArrayIndexOutOfBoundsException- if the co-ordinates are not in bounds
 - 
setPixelInt
public void setPixelInt(int x, int y, int pixelValue) Sets the pixel at the given pixel co-ordinate to the given pixel value.- Specified by:
 setPixelIntin classRasterDataNode- Parameters:
 x- The X co-ordinate of the pixel locationy- The Y co-ordinate of the pixel locationpixelValue- the new pixel value- Throws:
 NullPointerException- if this band has no raster data
 - 
setPixelFloat
public void setPixelFloat(int x, int y, float pixelValue) Sets the pixel at the given pixel coordinate to the given pixel value.- Specified by:
 setPixelFloatin classRasterDataNode- Parameters:
 x- The X co-ordinate of the pixel locationy- The Y co-ordinate of the pixel locationpixelValue- the new pixel value- Throws:
 NullPointerException- if this band has no raster data
 - 
setPixelDouble
public void setPixelDouble(int x, int y, double pixelValue) Sets the pixel value at the given pixel coordinate to the given pixel value.- Specified by:
 setPixelDoublein classRasterDataNode- Parameters:
 x- The X co-ordinate of the pixel locationy- The Y co-ordinate of the pixel locationpixelValue- the new pixel value- Throws:
 NullPointerException- if this band has no raster data
 - 
readPixels
public int[] readPixels(int x, int y, int w, int h, int[] pixels, ProgressMonitor pm) throws IOException Retrieves the band data at the given offset (x, y), width and height as integer data. If the data is already in memory, it merely copies the data to the buffer provided. If not, it calls the attached product reader to retrieve the data from the disk file. If the given buffer isnulla new one was created and returned.- Specified by:
 readPixelsin classRasterDataNode- Parameters:
 x- x offest of upper left cornery- y offset of upper left cornerw- width of the desired data arrayh- height of the desired data arraypixels- array of integer pixels to be filled with datapm- a monitor to inform the user about progress- Returns:
 - the pixels read
 - Throws:
 IllegalArgumentException- if the length of the given array is less thanw*h.IOException- if an /IO error occurs
 - 
readPixels
public float[] readPixels(int x, int y, int w, int h, float[] pixels, ProgressMonitor pm) throws IOException Retrieves the band data at the given offset (x, y), width and height as float data. If the data is already in memory, it merely copies the data to the buffer provided. If not, it calls the attached product reader to retrieve the data from the disk file. If the given buffer isnulla new one was created and returned.- Specified by:
 readPixelsin classRasterDataNode- Parameters:
 x- x offest of upper left cornery- y offset of upper left cornerw- width of the desired data arrayh- height of the desired data arraypixels- array of float pixels to be filled with data.pm- a monitor to inform the user about progress- Returns:
 - the pixels read
 - Throws:
 IllegalArgumentException- if the length of the given array is less thanw*h.IOException
 - 
readPixels
public double[] readPixels(int x, int y, int w, int h, double[] pixels, ProgressMonitor pm) throws IOException Retrieves the band data at the given offset (x, y), width and height as double data. If the data is already in memory, it merely copies the data to the buffer provided. If not, it calls the attached product reader to retrieve the data from the disk file. If the given buffer isnulla new one was created and returned.- Specified by:
 readPixelsin classRasterDataNode- Parameters:
 x- x offest of upper left cornery- y offset of upper left cornerw- width of the desired data arrayh- height of the desired data arraypixels- array of double pixels to be filled with datapm- a monitor to inform the user about progress- Returns:
 - the pixels read
 - Throws:
 IllegalArgumentException- if the length of the given array is less thanw*h.IOException
 - 
getPixels
Retrieves the range of pixels specified by the coordinates as integer array. Throws exception when the data is not read from disk yet. If the given array isnulla new one was created and returned.- Specified by:
 getPixelsin classRasterDataNode- Parameters:
 x- x offset into the bandy- y offset into the bandw- width of the pixel array to be readh- height of the pixel array to be read.pixels- integer array to be filled with datapm- a monitor to inform the user about progress- Throws:
 NullPointerException- if this band has no raster dataIllegalArgumentException- if the length of the given array is less thanw*h.
 - 
getPixels
Retrieves the range of pixels specified by the coordinates as float array. Throws exception when the data is not read from disk yet. If the given array isnulla new one was created and returned.- Specified by:
 getPixelsin classRasterDataNode- Parameters:
 x- x offset into the bandy- y offset into the bandw- width of the pixel array to be readh- height of the pixel array to be read.pixels- float array to be filled with datapm- a monitor to inform the user about progress- Throws:
 NullPointerException- if this band has no raster dataIllegalArgumentException- if the length of the given array is less thanw*h.
 - 
getPixels
Retrieves the range of pixels specified by the coordinates as double array. Throws exception when the data is not read from disk yet. If the given array isnulla new one was created and returned.- Specified by:
 getPixelsin classRasterDataNode- Parameters:
 x- x offset into the bandy- y offset into the bandw- width of the pixel array to be readh- height of the pixel array to be read.pixels- double array to be filled with datapm- a monitor to inform the user about progress- Throws:
 NullPointerException- if this band has no raster dataIllegalArgumentException- if the length of the given array is less thanw*h.
 - 
setPixels
public void setPixels(int x, int y, int w, int h, int[] pixels) Sets a range of pixels specified by the coordinates as integer array. Copies the data to the memory buffer of data at the specified location. Throws exception when the target buffer is not in memory.- Specified by:
 setPixelsin classRasterDataNode- Parameters:
 x- x offset into the bandy- y offset into the bandw- width of the pixel array to be writtenh- height of the pixel array to be written.pixels- integer array to be written- Throws:
 NullPointerException- if this band has no raster data
 - 
setPixels
public void setPixels(int x, int y, int w, int h, float[] pixels) Sets a range of pixels specified by the coordinates as float array. Copies the data to the memory buffer of data at the specified location. Throws exception when the target buffer is not in memory.- Specified by:
 setPixelsin classRasterDataNode- Parameters:
 x- x offset into the bandy- y offset into the bandw- width of the pixel array to be writtenh- height of the pixel array to be written.pixels- float array to be written
 - 
setPixels
public void setPixels(int x, int y, int w, int h, double[] pixels) Sets a range of pixels specified by the coordinates as double array. Copies the data to the memory buffer of data at the specified location. Throws exception when the target buffer is not in memory.- Specified by:
 setPixelsin classRasterDataNode- Parameters:
 x- x offset into the bandy- y offset into the bandw- width of the pixel array to be writtenh- height of the pixel array to be written.pixels- double array to be written
 - 
ensureRasterData
public void ensureRasterData()Ensures that raster data exists - 
loadRasterData
Loads the complete underlying raster data.After this method has been called successfully,
hasRasterData()should always returntrueandgetRasterData()should always return a validProductDatainstance with at leastgetRasterWidth()*getRasterHeight()elements (samples).In opposite to the
readRasterDataFullymethod,loadRasterDatawill only read data if this has not already been done.- Overrides:
 loadRasterDatain classRasterDataNode- Parameters:
 pm- a monitor to inform the user about progress- Throws:
 IOException- if an I/O error occurs- See Also:
 
 - 
unloadRasterData
public void unloadRasterData()Un-loads the raster data for this band.After this method has been called successfully, the
hasRasterData()method returnsfalseandgetRasterData()returnsnull.- Overrides:
 unloadRasterDatain classRasterDataNode- See Also:
 
 
 -