Class RasterDataNode

All Implemented Interfaces:
Extensible, Scaling, SceneTransformProvider
Direct Known Subclasses:
AbstractBand, TiePointGrid

public abstract class RasterDataNode extends DataNode implements Scaling, SceneTransformProvider
The RasterDataNode class ist the abstract base class for all objects in the product package that contain rasterized data. i.e. Band and TiePointGrid. It unifies the access to raster data in the product model. A raster is considered as a rectangular raw data array with a fixed width and height. A raster data node can scale its raw raster data samples in order to return geophysically meaningful pixel values.
See Also:
  • Field Details

  • Constructor Details

    • RasterDataNode

      protected RasterDataNode(String name, int dataType, long numElems)
      Constructs an object of type RasterDataNode.
      Parameters:
      name - the name of the new object
      dataType - the data type used by the raster, must be one of the multiple ProductData.TYPE_X constants, with the exception of ProductData.TYPE_UINT32
      numElems - the number of elements in this data node.
  • Method Details

    • getRasterWidth

      public abstract int getRasterWidth()
      Returns:
      The native width of the raster in pixels.
    • getRasterHeight

      public abstract int getRasterHeight()
      Returns:
      The native height of the raster in pixels.
    • getRasterSize

      public Dimension getRasterSize()
      Returns:
      The native size of the raster in pixels.
    • setModified

      public void setModified(boolean modified)
      Description copied from class: ProductNode
      Sets this node's modified flag.

      If the modified flag changes to true and this node has an owner, the owner's modified flag is also set to true.

      Overrides:
      setModified in class ProductNode
      Parameters:
      modified - whether or not this node is beeing marked as modified.
      See Also:
    • getImageToModelTransform

      public AffineTransform getImageToModelTransform()
      Gets the transformation used to convert this raster's image (pixel) coordinates to model coordinates used for rendering the image together with other images and vector data.

      If this raster data node's (source image is set) the image-to-model transformation of the image pyramid's lowest level image is returned. Otherwise the transformation which has been set using the setImageToModelTransform(AffineTransform) is returned. If the transformation was not set explicitly, the method tries to determine it from geo-codings. If this fails, the identity transform is returned.

      Returns:
      The image-to-model transformation.
      Since:
      SNAP 2.0
      See Also:
    • setImageToModelTransform

      public void setImageToModelTransform(AffineTransform imageToModelTransform)
      Sets the transformation used to convert this raster's image (pixel) coordinates to model coordinates used for rendering the image together with other images and vector data.

      The method call will fail if this raster data node has already a source image which uses a different image-to-model transformation.

      WARNING: This method belongs to a preliminary API and may change in an incompatible way or may even be removed in a next SNAP release.

      Parameters:
      imageToModelTransform - The new image-to-model transformation
      Throws:
      IllegalStateException - If a source image is already set which uses a different image-to-model transformation.
      Since:
      SNAP 2.0
      See Also:
    • getModelToSceneTransform

      public MathTransform2D getModelToSceneTransform()
      Gets the transformation that transforms from local RasterDataNode model coordinates to the Product's scene coordinates.

      If no model-to-scene transformation has been explicitly set but a scene-to-model transformation exists, then the latter's inverse() is returned.

      Specified by:
      getModelToSceneTransform in interface SceneTransformProvider
      Returns:
      The model-to-scene transformation, or null if no such exists.
      Since:
      SNAP 2.0.3
      See Also:
    • setModelToSceneTransform

      public void setModelToSceneTransform(MathTransform2D modelToSceneTransform)
      Sets a MathTransform2D from the local model CRS of this RasterDataNode to a Product's scene coordinate reference system. If the sceneToModelTransform is not the inverse of this transform or cannot be derived from it, it must be set using setSceneToModelTransform().

      Only use this method when you know that the model CRS of this RasterDataNode is different than the Product's scene CRS or when you want to model a special relationship between different RasterDataNode's. When no transformation from local model to scene is possible, use MathTransform2D.NULL.

      Parameters:
      modelToSceneTransform - The MathTransform2D to convert local model coordinates to product scene coordinates
      Since:
      SNAP 2.0.3
      See Also:
    • getSceneToModelTransform

      public MathTransform2D getSceneToModelTransform()
      Gets the transformation that transforms from the Product's scene coordinates to the local RasterDataNode model coordinates.

      If no scene-to-model transformation has been explicitly set but a model-to-scene transformation exists, then the latter's inverse() is returned.

      Specified by:
      getSceneToModelTransform in interface SceneTransformProvider
      Returns:
      The model-to-scene transformation
      Since:
      SNAP 2.0.3
      See Also:
    • setSceneToModelTransform

      public void setSceneToModelTransform(MathTransform2D sceneToModelTransform)
      Sets a MathTransform2D from a Product's scene coordinate reference system to the local model CRS of this RasterDataNode. If the modelToSceneTransform is not the inverse of this transformor cannot be derived from it, it must be set using setModelToSceneTransform().

      Only use this method when you know that the model CRS of this RasterDataNode is different than the Product's scene CRS or when you want to model a special relationship between different RasterDataNode's. When no transformation from scene to local model is possible, use MathTransform2D.NULL.

      Parameters:
      sceneToModelTransform - The MathTransform2D to convert product scene coordinates to local model coordinates
      Since:
      SNAP 2.0.3
      See Also:
    • hasGeoCoding

      public boolean hasGeoCoding()
      Check if raster has its own geocoding.
      Returns:
      true if raster has its own geocoding.
    • getGeoCoding

      public GeoCoding getGeoCoding()
      Returns the geo-coding of this RasterDataNode.
      Returns:
      the geo-coding, or null if not available.
    • setGeoCoding

      public void setGeoCoding(GeoCoding geoCoding)
      Sets the geo-coding for this RasterDataNode. Also sets the geo-coding of the parent Product if it has no geo-coding yet.

      On property change, the method calls ProductNode.fireProductNodeChanged(String) with the property name PROPERTY_NAME_GEO_CODING.

      Parameters:
      geoCoding - the new geo-coding
      See Also:
    • getTimeCoding

      public TimeCoding getTimeCoding()
      Gets the time-coding of this RasterDataNode.
      Returns:
      the time-coding, or null if not available.
      Since:
      SNAP 2.0
      See Also:
    • setTimeCoding

      public void setTimeCoding(TimeCoding timeCoding)
      Sets the time-coding for this RasterDataNode.
      Parameters:
      timeCoding - the new time-coding
      Since:
      SNAP 2.0
      See Also:
    • createPointing

      protected Pointing createPointing()
      Creates a Pointing applicable for this raster.
      Returns:
      the pointing object, or null if a pointing is not available
    • getPointing

      public Pointing getPointing()
      Gets a Pointing if one is available for this raster. The methods calls createPointing() if a pointing has not been set so far or if its GeoCoding changed since the last creation of this raster's Pointing instance.
      Returns:
      the pointing object, or null if a pointing is not available
    • canBeOrthorectified

      public boolean canBeOrthorectified()
      Tests if this raster data node can be orthorectified.
      Returns:
      true, if so
    • isFloatingPointType

      public boolean isFloatingPointType()
      Returns true if the pixel data contained in this band is "naturally" a floating point number type.
      Overrides:
      isFloatingPointType in class DataNode
      Returns:
      true, if so
    • getGeophysicalDataType

      public int getGeophysicalDataType()
      Returns the geophysical data type of this RasterDataNode. The value returned is always one of the ProductData.TYPE_XXX constants.
      Returns:
      the geophysical data type
      See Also:
    • getScalingFactor

      public final double getScalingFactor()
      Gets the scaling factor which is applied to raw ProductData. The default value is 1.0 (no factor).
      Returns:
      the scaling factor
      See Also:
    • setScalingFactor

      public final void setScalingFactor(double scalingFactor)
      Sets the scaling factor which is applied to raw ProductData.
      Parameters:
      scalingFactor - the scaling factor
      See Also:
    • getScalingOffset

      public final double getScalingOffset()
      Gets the scaling offset which is applied to raw ProductData. The default value is 0.0 (no offset).
      Returns:
      the scaling offset
      See Also:
    • setScalingOffset

      public final void setScalingOffset(double scalingOffset)
      Sets the scaling offset which is applied to raw ProductData.
      Parameters:
      scalingOffset - the scaling offset
      See Also:
    • isLog10Scaled

      public final boolean isLog10Scaled()
      Gets whether or not the ProductData of this band has a negative binomial distribution and thus the common logarithm (base 10) of the values is stored in the raw data. The default value is false.
      Returns:
      whether or not the data is logging-10 scaled
      See Also:
    • setLog10Scaled

      public final void setLog10Scaled(boolean log10Scaled)
      Sets whether or not the ProductData of this band has a negative binomial distribution and thus the common logarithm (base 10) of the values is stored in the raw data.
      Parameters:
      log10Scaled - whether or not the data is logging-10 scaled
      See Also:
    • isScalingApplied

      public final boolean isScalingApplied()
      Tests whether scaling of raw raster data values is applied before they are returned as geophysically meaningful pixel values.

      The methods which return geophysical pixel values are all getPixels(int, int, int, int, int[]), setPixels(int, int, int, int, int[]), readPixels(int, int, int, int, int[]) and writePixels(int, int, int, int, int[]) methods as well as the getPixel<Type> and setPixel<Type> methods such as getPixelFloat(int, int) * and setPixelFloat(int, int, float).

      Returns:
      true if a conversion is applyied to raw data samples before the are retuned.
      See Also:
    • isValidMaskProperty

      public static boolean isValidMaskProperty(String propertyName)
      Tests if the given name is the name of a property which is relevant for the computation of the valid mask.
      Parameters:
      propertyName - the name to test
      Returns:
      true, if so.
      Since:
      BEAM 4.2
    • isNoDataValueSet

      public boolean isNoDataValueSet()
      Tests whether or not a no-data value has been specified. The no-data value is not-specified unless either setNoDataValue(double) or setGeophysicalNoDataValue(double) is called.
      Returns:
      true, if so
      See Also:
    • clearNoDataValue

      public void clearNoDataValue()
      Clears the no-data value, so that isNoDataValueSet() will return false.
    • isNoDataValueUsed

      public boolean isNoDataValueUsed()
      Tests whether or not the no-data value is used.

      The no-data value is used to determine valid pixels. For more information on valid pixels, please refer to the documentation of the isPixelValid(int, int, javax.media.jai.ROI) method.

      Returns:
      true, if so
      See Also:
    • setNoDataValueUsed

      public void setNoDataValueUsed(boolean noDataValueUsed)
      Sets whether or not the no-data value is used. If the no-data value is enabled and the no-data value has not been set so far, a default no-data value it is set with a value of to zero.

      The no-data value is used to determine valid pixels. For more information on valid pixels, please refer to the documentation of the isPixelValid(int, int, javax.media.jai.ROI) method.

      On property change, the method calls ProductNode.fireProductNodeChanged(String) with the property name PROPERTY_NAME_NO_DATA_VALUE_USED.

      Parameters:
      noDataValueUsed - true, if so
      See Also:
    • getNoDataValue

      public double getNoDataValue()
      Gets the no-data value as a primitive double.

      Note that the value returned is NOT necessarily the same as the value returned by getGeophysicalNoDataValue() because no scaling is applied.

      The no-data value is used to determine valid pixels. For more information on valid pixels, please refer to the documentation of the isPixelValid(int, int, javax.media.jai.ROI) method.

      The method returns 0.0, if no no-data value has been specified so far.

      Returns:
      the no-data value. It is returned as a double in order to cover all other numeric types.
      See Also:
    • setNoDataValue

      public void setNoDataValue(double noDataValue)
      Sets the no-data value as a primitive double.

      Note that the given value is related to the "raw", un-scaled raster data. In order to set the geophysical, scaled no-data value use the method setGeophysicalNoDataValue(double).

      The no-data value is used to determine valid pixels. For more information on valid pixels, please refer to the documentation of the isPixelValid(int, int, javax.media.jai.ROI) method.

      On property change, the method calls ProductNode.fireProductNodeChanged(String) with the property name PROPERTY_NAME_NO_DATA_VALUE.

      Parameters:
      noDataValue - the no-data value. It is passed as a double in order to cover all other numeric types.
      See Also:
    • getGeophysicalNoDataValue

      public double getGeophysicalNoDataValue()
      Gets the geophysical no-data value which is simply the scaled "raw" no-data value returned by getNoDataValue().

      The no-data value is used to determine valid pixels. For more information on valid pixels, please refer to the documentation of the isPixelValid(int, int, javax.media.jai.ROI) method.

      Returns:
      the geophysical no-data value
      See Also:
    • setGeophysicalNoDataValue

      public void setGeophysicalNoDataValue(double noDataValue)
      Sets the geophysical no-data value which is simply the scaled "raw" no-data value returned by getNoDataValue().

      The no-data value is used to determine valid pixels. For more information on valid pixels, please refer to the documentation of the isPixelValid(int, int, javax.media.jai.ROI) method.

      On property change, the method calls ProductNode.fireProductNodeChanged(String) with the property name PROPERTY_NAME_NO_DATA_VALUE.

      Parameters:
      noDataValue - the new geophysical no-data value
      See Also:
    • getValidPixelExpression

      public String getValidPixelExpression()
      Gets the expression that is used to determine whether a pixel is valid or not. For more information on valid pixels, please refer to the documentation of the isPixelValid(int, int, javax.media.jai.ROI) method.
      Returns:
      the valid mask expression.
    • setValidPixelExpression

      public void setValidPixelExpression(String validPixelExpression)
      Sets the expression that is used to determine whether a pixel is valid or not.

      The valid-pixel expression is used to determine valid pixels. For more information on valid pixels, please refer to the documentation of the isPixelValid(int, int, javax.media.jai.ROI) method.

      On property change, the method calls ProductNode.fireProductNodeChanged(String) with the property name PROPERTY_NAME_VALID_PIXEL_EXPRESSION.

      Parameters:
      validPixelExpression - the valid mask expression, can be null
    • isValidMaskUsed

      public boolean isValidMaskUsed()
      Tests whether or not this raster data node uses a data-mask in order to determine valid pixels. The method returns true if either isValidPixelExpressionSet() or isNoDataValueUsed() returns true.

      The data-mask is used to determine valid pixels. For more information on valid pixels, please refer to the documentation of the isPixelValid(int, int, javax.media.jai.ROI) method.

      Returns:
      true, if so
    • resetValidMask

      public void resetValidMask()
      Resets the valid mask of this raster. The mask will be lazily regenerated when requested the next time.
    • getValidMaskExpression

      public String getValidMaskExpression()
      Gets the expression used for the computation of the mask which identifies valid pixel values. It recognizes the value of the noDataValue and the validPixelExpression properties, if any. The method returns null, if none of these properties are set.
      Returns:
      The expression used for the computation of the mask which identifies valid pixel values, or null.
      Since:
      BEAM 4.2
      See Also:
    • updateExpression

      public void updateExpression(String oldExternalName, String newExternalName)
      Asks a product node to replace all occurences of and references to the node name given by oldExternalName with oldExternalName. Such references most often occur in band arithmetic expressions.
      Overrides:
      updateExpression in class ProductNode
      Parameters:
      oldExternalName - The old node name.
      newExternalName - The new node name.
    • hasRasterData

      public boolean hasRasterData()
      Returns true if the raster data of this RasterDataNode is loaded or elsewhere available, otherwise false.
      Returns:
      true, if so.
    • getRasterData

      public ProductData getRasterData()
      Gets the raster data for this dataset. If the data hasn't been loaded so far the method returns null.
      Returns:
      the raster data for this band, or null if data has not been loaded
    • setRasterData

      public void setRasterData(ProductData rasterData)
      Sets the raster data of this dataset.

      Note that this method does not copy data at all. If the supplied raster data is compatible with this product raster, then simply its reference is stored. Modifications in the supplied raster data will also affect this dataset's data.

      Parameters:
      rasterData - The raster data for this raster data node.
      See Also:
    • loadRasterData

      public void loadRasterData() throws IOException
      Throws:
      IOException - if an I/O error occurs
      See Also:
    • loadRasterData

      public void loadRasterData(ProgressMonitor pm) throws IOException
      Loads the raster data for this RasterDataNode. After this method has been called successfully, hasRasterData() should always return true and getRasterData() should always return a valid ProductData instance with at least getRasterWidth()*getRasterHeight() elements (samples).

      The default implementation of this method does nothing.

      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 RasterDataNode.

      It is up to the implementation whether after this method has been called successfully, the hasRasterData() method returns false or true.

      The default implementation of this method does nothing.

      See Also:
    • removeCachedImageData

      public void removeCachedImageData()
    • dispose

      public void dispose()
      Releases all of the resources used by this object instance and all of its owned children. Its primary use is to allow the garbage collector to perform a vanilla job.

      This method should be called only if it is for sure that this object instance will never be used again. The results of referencing an instance of this class after a call to dispose() are undefined.

      Overrides of this method should always call super.dispose(); after disposing this instance.

      Overrides:
      dispose in class DataNode
    • isPixelValid

      public boolean isPixelValid(int x, int y)
      Checks whether or not the pixel located at (x,y) is valid. A pixel is assumed to be valid either if validMaskImage is null or or if the bit corresponding to (x,y) is set within the returned mask image.

      Note: Implementation changed by Norman (2011-08-09) in order to increase performance since a synchronised block was used due to problem with the JAI ROI class that has been used in the former implementation.

      Parameters:
      x - the X co-ordinate of the pixel location
      y - the Y co-ordinate of the pixel location
      Returns:
      true if the pixel is valid
      Throws:
      ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds
      See Also:
    • getSampleInt

      public int getSampleInt(int x, int y)
      Gets a geo-physical sample value at the given pixel coordinate as int value.

      Note: This method does not belong to the public API. It has been added by Norman (2011-08-09) in order to perform performance tests.

      Parameters:
      x - pixel X coordinate
      y - pixel Y coordinate
      Returns:
      The geo-physical sample value.
    • getSampleFloat

      public float getSampleFloat(int x, int y)
      Gets a geo-physical sample value at the given pixel coordinate as float value.

      Note: This method does not belong to the public API. It has been added by Norman (2011-08-09) in order to perform performance tests.

      Parameters:
      x - pixel X coordinate
      y - pixel Y coordinate
      Returns:
      The geo-physical sample value.
    • isPixelValid

      public boolean isPixelValid(int pixelIndex)
      Checks whether or not the pixel located at (x,y) is valid. A pixel is assumed to be valid either if validMaskImage is null or or if the bit corresponding to (x,y) is set within the returned mask image.
      Parameters:
      pixelIndex - the linear pixel index in the range 0 to width * height - 1
      Returns:
      true if the pixel is valid
      Throws:
      ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds
      Since:
      4.1
      See Also:
    • isPixelValid

      public boolean isPixelValid(int x, int y, javax.media.jai.ROI roi)
      Checks whether or not the pixel located at (x,y) is valid. The method first test whether a pixel is valid by using the isPixelValid(int, int) method, and secondly, if the pixel is within the ROI (if any).
      Parameters:
      x - the X co-ordinate of the pixel location
      y - the Y co-ordinate of the pixel location
      roi - the ROI, if null the method returns isPixelValid(int, int)
      Returns:
      true if the pixel is valid
      Throws:
      ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds
      See Also:
    • getPixelInt

      public abstract int getPixelInt(int x, int y)
      Returns the pixel located at (x,y) as an integer value.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded.

      Parameters:
      x - the X co-ordinate of the pixel location
      y - the Y co-ordinate of the pixel location
      Returns:
      the pixel value at (x,y)
      Throws:
      ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds
      IllegalStateException - if this object has no internal data buffer
    • getPixelFloat

      public abstract float getPixelFloat(int x, int y)
      Returns the pixel located at (x,y) as a float value.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded.

      Parameters:
      x - the X co-ordinate of the pixel location
      y - the Y co-ordinate of the pixel location
      Returns:
      the pixel value at (x,y)
      Throws:
      ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds
      IllegalStateException - if this object has no internal data buffer
    • getPixelDouble

      public abstract double getPixelDouble(int x, int y)
      Returns the pixel located at (x,y) as a double value.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded.

      Parameters:
      x - the X co-ordinate of the pixel location
      y - the Y co-ordinate of the pixel location
      Returns:
      the pixel value at (x,y)
      Throws:
      ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds
      IllegalStateException - if this object has no internal data buffer
    • setPixelInt

      public abstract void setPixelInt(int x, int y, int pixelValue)
      Sets the pixel located at (x,y) to the given integer value.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded.

      Parameters:
      x - the X co-ordinate of the pixel location
      y - the Y co-ordinate of the pixel location
      pixelValue - the new pixel value at (x,y)
      Throws:
      ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds
      IllegalStateException - if this object has no internal data buffer
    • setPixelFloat

      public abstract void setPixelFloat(int x, int y, float pixelValue)
      Sets the pixel located at (x,y) to the given float value.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded.

      Parameters:
      x - the X co-ordinate of the pixel location
      y - the Y co-ordinate of the pixel location
      pixelValue - the new pixel value at (x,y)
      Throws:
      ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds
      IllegalStateException - if this object has no internal data buffer
    • setPixelDouble

      public abstract void setPixelDouble(int x, int y, double pixelValue)
      Sets the pixel located at (x,y) to the given double value.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded.

      Parameters:
      x - the X co-ordinate of the pixel location
      y - the Y co-ordinate of the pixel location
      pixelValue - the new pixel value at (x,y)
      Throws:
      ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds
      IllegalStateException - if this object has no internal data buffer
    • getPixels

      public int[] getPixels(int x, int y, int w, int h, int[] pixels)
      See Also:
    • getPixels

      public abstract 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.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded. You can use the readPixels(int, int, int, int, double[], ProgressMonitor) method to read or compute pixel values without a raster data buffer.

      If the pixels array is null a new one will be created and returned.

      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be read
      h - height of the pixel array to be read.
      pixels - integer array to be filled with data
      pm - a progress monitor
      Throws:
      IllegalStateException - if this object has no internal data buffer
    • getPixels

      public float[] getPixels(int x, int y, int w, int h, float[] pixels)
      See Also:
    • getPixels

      public abstract 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.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded. You can use the readPixels(int, int, int, int, double[], ProgressMonitor) method to read or compute pixel values without a raster data buffer.

      If the pixels array is null a new one will be created and returned.

      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be read
      h - height of the pixel array to be read.
      pixels - float array to be filled with data
      pm - a progress monitor
      Throws:
      IllegalStateException - if this object has no internal data buffer
    • getPixels

      public abstract 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.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded. You can use the readPixels(int, int, int, int, double[], ProgressMonitor) method to read or compute pixel values without a raster data buffer.

      If the pixels array is null a new one will be created and returned.

      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be read
      h - height of the pixel array to be read.
      pixels - double array to be filled with data
      pm - a monitor to inform the user about progress
      Throws:
      IllegalStateException - if this object has no internal data buffer
    • setPixels

      public abstract void setPixels(int x, int y, int w, int h, int[] pixels)
      Sets a range of pixels specified by the coordinates as integer array.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded. You can use the writePixels(int, int, int, int, double[], ProgressMonitor) method to write pixels directly to the associated product writer.

      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be written
      h - height of the pixel array to be written.
      pixels - integer array to be written
      Throws:
      NullPointerException - if this band has no raster data
      IllegalStateException - if this object has no internal data buffer
    • setPixels

      public abstract void setPixels(int x, int y, int w, int h, float[] pixels)
      Sets a range of pixels specified by the coordinates as float array.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded. You can use the writePixels(int, int, int, int, double[], ProgressMonitor) method to write pixels directly to the associated product writer.

      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be written
      h - height of the pixel array to be written.
      pixels - float array to be written
      Throws:
      NullPointerException - if this band has no raster data
      IllegalStateException - if this object has no internal data buffer
    • setPixels

      public abstract void setPixels(int x, int y, int w, int h, double[] pixels)
      Sets a range of pixels specified by the coordinates as double array.

      Note that this method can only be used if this object's internal raster data buffer has been set or loaded. You can use the writePixels(int, int, int, int, double[], ProgressMonitor) method to write pixels directly to the associated product writer.

      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be written
      h - height of the pixel array to be written.
      pixels - double array to be written
      Throws:
      NullPointerException - if this band has no raster data
      IllegalStateException - if this object has no internal data buffer
    • readPixels

      public int[] readPixels(int x, int y, int w, int h, int[] pixels) throws IOException
      Throws:
      IOException
      See Also:
    • readPixels

      public abstract 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 int 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 or operator to read or compute the data.

      If the pixels array is null a new one will be created and returned.

      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be read
      h - height of the pixel array to be read
      pixels - array to be filled with data
      pm - a progress monitor
      Returns:
      the pixels read
      Throws:
      IOException - if an /IO error occurs
      IllegalStateException - if this object has no attached product reader
    • readPixels

      public float[] readPixels(int x, int y, int w, int h, float[] pixels) throws IOException
      Throws:
      IOException
      See Also:
    • readPixels

      public abstract 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 int 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 or operator to read or compute the data.

      If the pixels array is null a new one will be created and returned.

      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be read
      h - height of the pixel array to be read
      pixels - array to be filled with data
      pm - a progress monitor
      Returns:
      the pixels read
      Throws:
      IllegalStateException - if this object has no attached product reader
      IOException
    • readPixels

      public double[] readPixels(int x, int y, int w, int h, double[] pixels) throws IOException
      Throws:
      IOException
      See Also:
    • readPixels

      public abstract 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 int 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 or operator to read or compute the data.

      If the pixels array is null a new one will be created and returned.

      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be read
      h - height of the pixel array to be read
      pixels - array to be filled with data
      pm - a progress monitor
      Returns:
      the pixels read
      Throws:
      IllegalStateException - if this object has no attached product reader
      IOException
    • writePixels

      public void writePixels(int x, int y, int w, int h, int[] pixels) throws IOException
      Throws:
      IOException
      See Also:
    • writePixels

      public abstract void writePixels(int x, int y, int w, int h, int[] pixels, ProgressMonitor pm) throws IOException
      Writes the range of given pixels specified to the specified coordinates as integers.
      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be written
      h - height of the pixel array to be written
      pixels - array of pixels to write
      pm - a progress monitor
      Throws:
      IllegalStateException - if this object has no attached product writer
      IOException - if an I/O error occurs
    • writePixels

      public void writePixels(int x, int y, int w, int h, float[] pixels) throws IOException
      Throws:
      IOException
      See Also:
    • writePixels

      public abstract void writePixels(int x, int y, int w, int h, float[] pixels, ProgressMonitor pm) throws IOException
      Writes the range of given pixels specified to the specified coordinates as floats.
      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be written
      h - height of the pixel array to be written
      pixels - array of pixels to write
      pm - a progress monitor
      Throws:
      IllegalStateException - if this object has no attached product writer
      IOException - if an I/O error occurs
    • writePixels

      public void writePixels(int x, int y, int w, int h, double[] pixels) throws IOException
      Throws:
      IOException
      See Also:
    • writePixels

      public abstract void writePixels(int x, int y, int w, int h, double[] pixels, ProgressMonitor pm) throws IOException
      Writes the range of given pixels specified to the specified coordinates as doubles.
      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be written
      h - height of the pixel array to be written
      pixels - array of pixels to write
      pm - a progress monitor
      Throws:
      IllegalStateException - if this object has no attached product writer
      IOException - if an I/O error occurs
    • readValidMask

      public boolean[] readValidMask(int x, int y, int w, int h, boolean[] validMask) throws IOException
      Reads the valid mask values for the specified area. The mask indicates if a pixel is valid or not. The values are retrieved from the getValidMaskImage(). For a single pixel it is also possible to us isPixelValid(int, int)
      Parameters:
      x - x offset into the band
      y - y offset into the band
      w - width of the pixel array to be written
      h - height of the pixel array to be written
      validMask - mask for the specified area if the pixels are valid. Can be null, then a new array will be created and returned. If the array is provided it must have the size (w * h)
      Returns:
      the valid mask. Either the provided array or a newly created.
      Throws:
      IOException - if an I/O error occurs
      See Also:
    • readRasterDataFully

      public void readRasterDataFully() throws IOException
      Throws:
      IOException - if an I/O error occurs
      See Also:
    • readRasterDataFully

      public abstract void readRasterDataFully(ProgressMonitor pm) throws IOException
      Reads the complete underlying raster data.

      After this method has been called successfully, hasRasterData() should always return true and getRasterData() should always return a valid ProductData instance with at least getRasterWidth()*getRasterHeight() elements (samples).

      In opposite to the loadRasterData method, the readRasterDataFully method always reloads the data of this product raster, independently of whether its has already been loaded or not.

      Parameters:
      pm - a monitor to inform the user about progress
      Throws:
      IOException - if an I/O error occurs
      See Also:
    • readRasterData

      public void readRasterData(int offsetX, int offsetY, int width, int height, ProductData rasterData) throws IOException
      Reads raster data from the node's associated data source into the given data buffer.
      Parameters:
      offsetX - the X-offset in the raster co-ordinates where reading starts
      offsetY - the Y-offset in the raster co-ordinates where reading starts
      width - the width of the raster data buffer
      height - the height of the raster data buffer
      rasterData - a raster data buffer receiving the pixels to be read
      Throws:
      IOException - if an I/O error occurs
      IllegalArgumentException - if the raster is null
      IllegalStateException - if this product raster was not added to a product so far, or if the product to which this product raster belongs to, has no associated product reader
      See Also:
    • readRasterData

      public abstract void readRasterData(int offsetX, int offsetY, int width, int height, ProductData rasterData, ProgressMonitor pm) throws IOException
      The method behaves exactly as readRasterData(int, int, int, int, ProductData), but clients can additionally pass a ProgressMonitor.
      Parameters:
      offsetX - the X-offset in the raster co-ordinates where reading starts
      offsetY - the Y-offset in the raster co-ordinates where reading starts
      width - the width of the raster data buffer
      height - the height of the raster data buffer
      rasterData - a raster data buffer receiving the pixels to be read
      pm - a monitor to inform the user about progress
      Throws:
      IOException - if an I/O error occurs
      IllegalArgumentException - if the raster is null
      IllegalStateException - if this product raster was not added to a product so far, or if the product to which this product raster belongs to, has no associated product reader
    • writeRasterDataFully

      public void writeRasterDataFully() throws IOException
      Throws:
      IOException
    • writeRasterDataFully

      public abstract void writeRasterDataFully(ProgressMonitor pm) throws IOException
      Writes the complete underlying raster data.
      Parameters:
      pm - a monitor to inform the user about progress
      Throws:
      IOException - if an I/O error occurs
    • writeRasterData

      public void writeRasterData(int offsetX, int offsetY, int width, int height, ProductData rasterData) throws IOException
      Throws:
      IOException
    • writeRasterData

      public abstract void writeRasterData(int offsetX, int offsetY, int width, int height, ProductData rasterData, ProgressMonitor pm) throws IOException
      Writes data from this product raster into the specified region of the user-supplied raster.

      It is important to know that this method does not change this product raster's internal state nor does it write into this product raster's internal raster.

      Parameters:
      offsetX - the X-offset in raster co-ordinates where reading starts
      offsetY - the Y-offset in raster co-ordinates where reading starts
      width - the width of the raster data buffer
      height - the height of the raster data buffer
      rasterData - a raster data buffer receiving the pixels to be read
      pm - a monitor to inform the user about progress
      Throws:
      IOException - if an I/O error occurs
      IllegalArgumentException - if the raster is null
      IllegalStateException - if this product raster was not added to a product so far, or if the product to which this product raster belongs to, has no associated product reader
      See Also:
    • createCompatibleRasterData

      public ProductData createCompatibleRasterData()
      Creates raster data that is compatible to this dataset's data type. The data buffer returned contains exactly getRasterWidth()*getRasterHeight() elements of a compatible data type.
      Returns:
      raster data compatible with this product raster
      See Also:
    • createCompatibleSceneRasterData

      public ProductData createCompatibleSceneRasterData()
      Creates raster data that is compatible to this dataset's data type. The data buffer returned contains exactly getBandOutputRasterWidth()*getBandOutputRasterHeight() elements of a compatible data type.
      Returns:
      raster data compatible with this product raster
      See Also:
    • createCompatibleRasterData

      public ProductData createCompatibleRasterData(int width, int height)
      Creates raster data that is compatible to this dataset's data type. The data buffer returned contains exactly width*height elements of a compatible data type.
      Parameters:
      width - the width of the raster data to be created
      height - the height of the raster data to be created
      Returns:
      raster data compatible with this product raster
      See Also:
    • isCompatibleRasterData

      public boolean isCompatibleRasterData(ProductData rasterData, int w, int h)
      Tests whether the given parameters specify a compatible raster or not.
      Parameters:
      rasterData - the raster data
      w - the raster width
      h - the raster height
      Returns:
      true if so
    • checkCompatibleRasterData

      public void checkCompatibleRasterData(ProductData rasterData, int w, int h)
      Throws an IllegalArgumentException if the given parameters dont specify a compatible raster.
      Parameters:
      rasterData - the raster data
      w - the raster width
      h - the raster height
    • hasIntPixels

      public boolean hasIntPixels()
      Determines whether this raster data node contains integer samples.
      Returns:
      true if this raster data node contains integer samples.
    • createTransectProfileData

      public TransectProfileData createTransectProfileData(Shape shape) throws IOException
      Creates a transect profile for the given shape (-outline).
      Parameters:
      shape - the shape
      Returns:
      the profile data
      Throws:
      IOException - if an I/O error occurs
    • acceptVisitor

      public abstract void acceptVisitor(ProductVisitor visitor)
      Accepts the given visitor. This method implements the well known 'Visitor' design pattern of the gang-of-four. The visitor pattern allows to define new operations on the product data model without the need to add more code to it. The new operation is implemented by the visitor.
      Specified by:
      acceptVisitor in class DataNode
      Parameters:
      visitor - the visitor, must not be null
    • getImageInfo

      public ImageInfo getImageInfo()
      Gets the image information for image display.
      Returns:
      the image info or null
    • setImageInfo

      public void setImageInfo(ImageInfo imageInfo)
      Sets the image information for image display.
      Parameters:
      imageInfo - the image info, can be null
    • setImageInfo

      protected void setImageInfo(ImageInfo imageInfo, boolean change)
    • fireImageInfoChanged

      public void fireImageInfoChanged()
      Notifies listeners that the image (display) information has changed.
      Since:
      BEAM 4.7
    • getImageInfo

      public final ImageInfo getImageInfo(ProgressMonitor pm)
      Returns the image information for this raster data node.

      The method simply returns the value of ensureValidImageInfo(null, ProgressMonitor.NULL).

      Parameters:
      pm - A progress monitor.
      Returns:
      A valid image information instance.
      Since:
      BEAM 4.2
      See Also:
    • getImageInfo

      public final ImageInfo getImageInfo(double[] histoSkipAreas, ProgressMonitor pm)
      Gets the image creation information.

      If no image information has been assigned before, the createDefaultImageInfo(double[], com.bc.ceres.core.ProgressMonitor) method is called with the given parameters passed to this method.

      Parameters:
      histoSkipAreas - Only used, if new image info is created (see createDefaultImageInfo(double[], com.bc.ceres.core.ProgressMonitor) method).
      pm - A progress monitor.
      Returns:
      The image creation information.
      Since:
      BEAM 4.2
    • createDefaultImageInfo

      public ImageInfo createDefaultImageInfo(double[] histoSkipAreas, ProgressMonitor pm)
      Creates a default image information instance.

      An IllegalStateException is thrown in the case that this raster data node has no raster data.

      Parameters:
      histoSkipAreas - the left (at index 0) and right (at index 1) normalized areas of the raster data histogram to be excluded when determining the value range for a linear constrast stretching. Can be null, in this case {0.01, 0.04} resp. 5% of the entire area is skipped.
      pm - a monitor to inform the user about progress
      Returns:
      a valid image information instance, never null.
    • createDefaultImageInfo

      public final ImageInfo createDefaultImageInfo(double[] histoSkipAreas, Histogram histogram)
      Creates an instance of a default image information.

      An IllegalStateException is thrown in the case that this raster data node has no raster data.

      Parameters:
      histoSkipAreas - the left (at index 0) and right (at index 1) normalized areas of the raster data histogram to be excluded when determining the value range for a linear constrast stretching. Can be null, in this case {0.01, 0.04} resp. 5% of the entire area is skipped.
      histogram - the histogram to create the image information.
      Returns:
      a valid image information instance, never null.
    • getOverlayMaskGroup

      public ProductNodeGroup<Mask> getOverlayMaskGroup()
      Returns:
      The overlay mask group.
    • createColorIndexedImage

      public BufferedImage createColorIndexedImage(ProgressMonitor pm) throws IOException
      Creates an image for this raster data node. The method simply returns ProductUtils.createColorIndexedImage(this, null).
      Parameters:
      pm - a monitor to inform the user about progress
      Returns:
      a greyscale/palette-based image for this raster data node
      Throws:
      IOException - if the raster data is not loaded so far and reload causes an I/O error
      See Also:
    • createRgbImage

      public BufferedImage createRgbImage(ProgressMonitor pm) throws IOException
      Creates an RGB image for this raster data node.
      Parameters:
      pm - a monitor to inform the user about progress
      Returns:
      a greyscale/palette-based image for this raster data node
      Throws:
      IOException - if the raster data is not loaded so far and reload causes an I/O error
      See Also:
    • quantizeRasterData

      public byte[] quantizeRasterData(double newMin, double newMax, double gamma, ProgressMonitor pm) throws IOException
      Throws:
      IOException
    • quantizeRasterData

      public void quantizeRasterData(double newMin, double newMax, double gamma, byte[] samples, int offset, int stride, ProgressMonitor pm) throws IOException
      Throws:
      IOException
    • scale

      public final double scale(double v)
      Applies the scaling v * scalingFactor + scalingOffset the given input value. If the log10Scaled property is true, the result is taken to the power of 10 after the actual scaling.
      Specified by:
      scale in interface Scaling
      Parameters:
      v - the input value
      Returns:
      the scaled value
    • scaleInverse

      public final double scaleInverse(double v)
      Applies the inverse scaling (v - scalingOffset) / scalingFactor the given input value. If the log10Scaled property is true, the common logarithm is applied to the input before the actual scaling.
      Specified by:
      scaleInverse in interface Scaling
      Parameters:
      v - the input value
      Returns:
      the scaled value
    • getPixelString

      public String getPixelString(int x, int y)
      Returns the pixel located at (x,y) as a string value.
      Parameters:
      x - the X co-ordinate of the pixel location
      y - the Y co-ordinate of the pixel location
      Returns:
      the pixel value at (x,y) as string or an error message text
    • isPixelWithinImageBounds

      public boolean isPixelWithinImageBounds(int x, int y)
    • isSourceImageSet

      public boolean isSourceImageSet()
      Returns whether the source image is set on this RasterDataNode.
      Returns:
      whether the source image is set.
      Since:
      BEAM 4.5
      See Also:
    • getSourceImage

      public MultiLevelImage getSourceImage()
      Gets the source image associated with this RasterDataNode.
      Returns:
      The source image. Never null. In the case that isSourceImageSet() returns false, the method createSourceImage() will be called in order to set and return a valid source image.
      Since:
      BEAM 4.2
      See Also:
    • createSourceImage

      protected abstract RenderedImage createSourceImage()
      Creates the source image associated with this RasterDataNode. This shall preferably be a MultiLevelImage instance which recognises this raster data node's imageToModelTransform property, if set.
      Returns:
      A new source image instance.
      Since:
      BEAM 4.5
    • setSourceImage

      public void setSourceImage(RenderedImage sourceImage)
      Sets the source image associated with this RasterDataNode.
      Parameters:
      sourceImage - The source image. Can be null. If so, isSourceImageSet() will return false.
      Since:
      BEAM 4.2
    • setSourceImage

      public void setSourceImage(MultiLevelImage sourceImage)
      Sets the source image associated with this RasterDataNode.
      Parameters:
      sourceImage - The source image. Can be null. If so, isSourceImageSet() will return false.
      Since:
      BEAM 4.6
    • isGeophysicalImageSet

      public boolean isGeophysicalImageSet()
      Returns whether the geophysical image is set on this RasterDataNode.

      This method belongs to preliminary API and may be removed or changed in the future.

      Returns:
      whether the geophysical image is set.
      Since:
      BEAM 4.6
    • getGeophysicalImage

      public MultiLevelImage getGeophysicalImage()
      Returns:
      The geophysical source image.
      Since:
      BEAM 4.5
    • getMultiLevelModel

      public MultiLevelModel getMultiLevelModel()
      Gets the multi-level image (image pyramid) model that describes an image pyramid layout. If this raster data node has a source image, its multi-level model will be returned. Otherwise a new model will be created using createMultiLevelModel().
      Returns:
      The multi-level image (image pyramid) model
      See Also:
    • createMultiLevelModel

      public MultiLevelModel createMultiLevelModel()
      Create a multi-level image model suited for source and geo-physical images returned by this RasterDataNode
      Returns:
      A new suitable multi-level image (image pyramid) model
      See Also:
    • isValidMaskImageSet

      public boolean isValidMaskImageSet()
      Returns whether the valid mask image is set on this RasterDataNode.
      Returns:
      Whether the source image is set.
      Since:
      BEAM 4.5
    • getValidMaskImage

      public MultiLevelImage getValidMaskImage()
      Gets the valid-mask image associated with this RasterDataNode. The image is based on the getValidMaskExpression()
      Returns:
      The rendered image.
      Since:
      BEAM 4.2
    • isStxSet

      public boolean isStxSet()
    • getStx

      public Stx getStx()
      Gets the statistics. If statistics are not yet available, the method will compute (possibly inaccurate) statistics and return those.

      If accurate statistics are required, the getStx(boolean, com.bc.ceres.core.ProgressMonitor) shall be used instead.

      This method belongs to preliminary API and may be removed or changed in the future.

      Returns:
      The statistics.
      Since:
      BEAM 4.2, revised in BEAM 4.5
      See Also:
    • getStx

      public Stx getStx(boolean accurate, ProgressMonitor pm)
      Gets the statistics. If the statistics have not been set before they are computed using the given progress monitor pm and then set. This method belongs to preliminary API and may be removed or changed in the future.
      Parameters:
      accurate - If true, accurate statistics are computed.
      pm - A progress monitor which is used to compute the new statistics, if required.
      Returns:
      The statistics.
      Since:
      since BEAM 4.5
    • setStx

      public void setStx(Stx stx)
      Sets the statistics. It is the responsibility of the caller to ensure that the given statistics are really related to this RasterDataNode's raster data. The method fires a property change event for the property PROPERTY_NAME_STX. This method belongs to preliminary API and may be removed or changed in the future.
      Parameters:
      stx - The statistics.
      Since:
      BEAM 4.2, revised in BEAM 4.5
    • computeStxImpl

      protected Stx computeStxImpl(int level, ProgressMonitor pm)
      Computes the statistics. May be overridden. This method belongs to preliminary API and may be removed or changed in the future.
      Parameters:
      level - The resolution level.
      pm - A progress monitor.
      Returns:
      The statistics.
      Since:
      BEAM 4.5
    • getValidShape

      public Shape getValidShape()
      Gets the shape of the area where this raster data contains valid samples. The method returns null, if the entire raster contains valid samples.
      Returns:
      The shape of the area where the raster data has samples, can be null.
      Since:
      BEAM 4.7
    • getAncillaryVariable

      public RasterDataNode getAncillaryVariable(String... relations)
      Finds the first associated ancillary band for the specified relations.
      Parameters:
      relations - Names of relations such as "uncertainty", "variance", or null (any).
      Returns:
      The associated ancillary band or null.
      Since:
      SNAP 2.0
    • getAncillaryVariables

      public RasterDataNode[] getAncillaryVariables(String... relations)
      Finds any associated ancillary band for the specified relation.
      Parameters:
      relations - Names of relations such as "uncertainty", "variance", or null (any).
      Returns:
      The associated ancillary bands or an empty array.
      Since:
      SNAP 2.0
    • addAncillaryVariable

      public void addAncillaryVariable(RasterDataNode variable, String... relations)
      Adds an associated ancillary variable and sets its relation names.
      Parameters:
      variable - The associated ancillary variable.
      relations - The names of the relations, may be "uncertainty", "variance", or null (not set).
      Since:
      SNAP 2.0
    • removeAncillaryVariable

      public void removeAncillaryVariable(RasterDataNode variable)
      Removes an associated ancillary variable.
      Parameters:
      variable - The associated ancillary variable.
      Since:
      SNAP 2.0
    • getAncillaryRelations

      public String[] getAncillaryRelations()
      Gets the names of an ancillary relations to another raster data node. See NetCDF-U 'rel' attribute.
      Returns:
      The names of an ancillary relations to another raster data node, or an empty array.
      Since:
      SNAP 2.0
      See Also:
    • setAncillaryRelations

      public void setAncillaryRelations(String... relations)
      Sets the names of an ancillary relations to another raster data node. See NetCDF-U 'rel' attribute.
      Parameters:
      relations - The names of an ancillary relations.
      Since:
      SNAP 2.0
      See Also:
    • processRasterData

      public void processRasterData(String message, RasterDataNode.RasterDataProcessor processor, ProgressMonitor pm) throws IOException
      Processes the raster's data.

      Users of this method may also consider implementing a GPF org.esa.snap.core.gpf.Operator or a SingleBandedOpImage instead.

      Parameters:
      message - a task description
      processor - the raster processor
      pm - a progress monitor
      Throws:
      IOException