Class RasterDataNode

    • Constructor Detail

      • 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 Detail

      • 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.
      • 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:
        getImageToModelTransform(), createSourceImage()
      • 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:
        setSceneToModelTransform(MathTransform2D)
      • 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:
        setModelToSceneTransform(MathTransform2D)
      • getGeoCoding

        public GeoCoding getGeoCoding()
        Returns the geo-coding of this RasterDataNode.
        Returns:
        the geo-coding, or null if not available.
      • 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:
        ProductData, isScalingApplied()
      • 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:
        isScalingApplied()
      • setScalingFactor

        public final void setScalingFactor​(double scalingFactor)
        Sets the scaling factor which is applied to raw ProductData.
        Parameters:
        scalingFactor - the scaling factor
        See Also:
        isScalingApplied()
      • 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:
        isScalingApplied()
      • setScalingOffset

        public final void setScalingOffset​(double scalingOffset)
        Sets the scaling offset which is applied to raw ProductData.
        Parameters:
        scalingOffset - the scaling offset
        See Also:
        isScalingApplied()
      • 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:
        isScalingApplied()
      • 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()
      • 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
      • clearNoDataValue

        public void clearNoDataValue()
        Clears the no-data value, so that isNoDataValueSet() will return false.
      • 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(double), isNoDataValueSet(), isNoDataValueUsed()
      • 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.
      • 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:
        getValidPixelExpression(), getNoDataValue()
      • 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:
        getRasterData()
      • 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()
      • 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:
        loadRasterData()
      • 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
      • 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.
      • 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 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 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 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 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 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 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 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 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:
        getValidMaskImage(), getValidPixelExpression(), isPixelValid(int, int)
      • 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:
        loadRasterData(), readRasterData(int, int, int, int, ProductData, com.bc.ceres.core.ProgressMonitor)
      • 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:
        ProductReader.readBandRasterData(Band, int, int, int, int, ProductData, com.bc.ceres.core.ProgressMonitor)
      • 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 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:
        rasterData - a raster data buffer receiving the pixels to be read
        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
        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:
        ProductReader.readBandRasterData(Band, int, int, int, int, ProductData, com.bc.ceres.core.ProgressMonitor)
      • 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()
      • 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()
      • 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:
        createCompatibleRasterData(), createCompatibleSceneRasterData()
      • 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(double[], ProgressMonitor)
      • 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:
        setImageInfo(ImageInfo)
      • 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:
        setImageInfo(ImageInfo)
      • 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)
      • 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 {@link ##getImageToModelTransform() 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()
      • 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​(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