Class RasterDataNode
- java.lang.Object
-
- com.bc.ceres.core.ExtensibleObject
-
- org.esa.snap.core.datamodel.ProductNode
-
- org.esa.snap.core.datamodel.DataNode
-
- org.esa.snap.core.datamodel.RasterDataNode
-
- All Implemented Interfaces:
Extensible
,Scaling
,SceneTransformProvider
- Direct Known Subclasses:
AbstractBand
,TiePointGrid
public abstract class RasterDataNode extends DataNode implements Scaling, SceneTransformProvider
TheRasterDataNode
class ist the abstract base class for all objects in the product package that contain rasterized data. i.e.Band
andTiePointGrid
. 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RasterDataNode.RasterDataProcessor
A raster data processor which is called for a set of raster lines to be processed.
-
Field Summary
-
Fields inherited from class org.esa.snap.core.datamodel.DataNode
PROPERTY_NAME_DATA, PROPERTY_NAME_READ_ONLY, PROPERTY_NAME_SYNTHETIC, PROPERTY_NAME_UNIT
-
Fields inherited from class org.esa.snap.core.datamodel.ProductNode
PROPERTY_NAME_DESCRIPTION, PROPERTY_NAME_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RasterDataNode(String name, int dataType, long numElems)
Constructs an object of typeRasterDataNode
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
acceptVisitor(ProductVisitor visitor)
Accepts the given visitor.void
addAncillaryVariable(RasterDataNode variable, String... relations)
Adds an associated ancillary variable and sets its relation names.boolean
canBeOrthorectified()
Tests if this raster data node can be orthorectified.void
checkCompatibleRasterData(ProductData rasterData, int w, int h)
Throws anIllegalArgumentException
if the given parameters dont specify a compatible raster.void
clearNoDataValue()
Clears the no-data value, so thatisNoDataValueSet()
will returnfalse
.protected Stx
computeStxImpl(int level, ProgressMonitor pm)
Computes the statistics.BufferedImage
createColorIndexedImage(ProgressMonitor pm)
Creates an image for this raster data node.ProductData
createCompatibleRasterData()
Creates raster data that is compatible to this dataset's data type.ProductData
createCompatibleRasterData(int width, int height)
Creates raster data that is compatible to this dataset's data type.ProductData
createCompatibleSceneRasterData()
Creates raster data that is compatible to this dataset's data type.ImageInfo
createDefaultImageInfo(double[] histoSkipAreas, ProgressMonitor pm)
Creates a default image information instance.ImageInfo
createDefaultImageInfo(double[] histoSkipAreas, Histogram histogram)
Creates an instance of a default image information.MultiLevelModel
createMultiLevelModel()
Create a multi-level image model suited for source and geo-physical images returned by thisRasterDataNode
protected Pointing
createPointing()
Creates aPointing
applicable for this raster.BufferedImage
createRgbImage(ProgressMonitor pm)
Creates an RGB image for this raster data node.protected abstract RenderedImage
createSourceImage()
Creates the source image associated with thisRasterDataNode
.TransectProfileData
createTransectProfileData(Shape shape)
Creates a transect profile for the given shape (-outline).void
dispose()
Releases all of the resources used by this object instance and all of its owned children.void
fireImageInfoChanged()
Notifies listeners that the image (display) information has changed.String[]
getAncillaryRelations()
Gets the names of an ancillary relations to another raster data node.RasterDataNode
getAncillaryVariable(String... relations)
Finds the first associated ancillary band for the specified relations.RasterDataNode[]
getAncillaryVariables(String... relations)
Finds any associated ancillary band for the specified relation.GeoCoding
getGeoCoding()
Returns the geo-coding of thisRasterDataNode
.int
getGeophysicalDataType()
Returns the geophysical data type of thisRasterDataNode
.MultiLevelImage
getGeophysicalImage()
double
getGeophysicalNoDataValue()
Gets the geophysical no-data value which is simply the scaled "raw" no-data value returned bygetNoDataValue()
.ImageInfo
getImageInfo()
Gets the image information for image display.ImageInfo
getImageInfo(double[] histoSkipAreas, ProgressMonitor pm)
Gets the image creation information.ImageInfo
getImageInfo(ProgressMonitor pm)
Returns the image information for this raster data node.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.MathTransform2D
getModelToSceneTransform()
Gets the transformation that transforms from localRasterDataNode
model coordinates to theProduct
's scene coordinates.MultiLevelModel
getMultiLevelModel()
Gets the multi-level image (image pyramid) model that describes an image pyramid layout.double
getNoDataValue()
Gets the no-data value as a primitivedouble
.ProductNodeGroup<Mask>
getOverlayMaskGroup()
abstract double
getPixelDouble(int x, int y)
Returns the pixel located at (x,y) as a double value.abstract float
getPixelFloat(int x, int y)
Returns the pixel located at (x,y) as a float value.abstract int
getPixelInt(int x, int y)
Returns the pixel located at (x,y) as an integer value.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.float[]
getPixels(int x, int y, int w, int h, float[] pixels)
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.int[]
getPixels(int x, int y, int w, int h, int[] pixels)
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.String
getPixelString(int x, int y)
Returns the pixel located at (x,y) as a string value.Pointing
getPointing()
Gets aPointing
if one is available for this raster.ProductData
getRasterData()
Gets the raster data for this dataset.abstract int
getRasterHeight()
Dimension
getRasterSize()
abstract int
getRasterWidth()
float
getSampleFloat(int x, int y)
Gets a geo-physical sample value at the given pixel coordinate asfloat
value.int
getSampleInt(int x, int y)
Gets a geo-physical sample value at the given pixel coordinate asint
value.double
getScalingFactor()
Gets the scaling factor which is applied to rawProductData
.double
getScalingOffset()
Gets the scaling offset which is applied to rawProductData
.MathTransform2D
getSceneToModelTransform()
Gets the transformation that transforms from theProduct
's scene coordinates to the localRasterDataNode
model coordinates.MultiLevelImage
getSourceImage()
Gets the source image associated with thisRasterDataNode
.Stx
getStx()
Gets the statistics.Stx
getStx(boolean accurate, ProgressMonitor pm)
Gets the statistics.TimeCoding
getTimeCoding()
Gets the time-coding of thisRasterDataNode
.String
getValidMaskExpression()
Gets the expression used for the computation of the mask which identifies valid pixel values.MultiLevelImage
getValidMaskImage()
Gets the valid-mask image associated with thisRasterDataNode
.String
getValidPixelExpression()
Gets the expression that is used to determine whether a pixel is valid or not.Shape
getValidShape()
Gets the shape of the area where this raster data contains valid samples.boolean
hasIntPixels()
Determines whether this raster data node contains integer samples.boolean
hasRasterData()
Returns true if the raster data of thisRasterDataNode
is loaded or elsewhere available, otherwise false.boolean
isCompatibleRasterData(ProductData rasterData, int w, int h)
Tests whether the given parameters specify a compatible raster or not.boolean
isFloatingPointType()
Returnstrue
if the pixel data contained in this band is "naturally" a floating point number type.boolean
isGeophysicalImageSet()
Returns whether the geophysical image is set on thisRasterDataNode
.boolean
isLog10Scaled()
Gets whether or not theProductData
of this band has a negative binomial distribution and thus the common logarithm (base 10) of the values is stored in the raw data.boolean
isNoDataValueSet()
Tests whether or not a no-data value has been specified.boolean
isNoDataValueUsed()
Tests whether or not the no-data value is used.boolean
isPixelValid(int pixelIndex)
Checks whether or not the pixel located at (x,y) is valid.boolean
isPixelValid(int x, int y)
Checks whether or not the pixel located at (x,y) is valid.boolean
isPixelValid(int x, int y, javax.media.jai.ROI roi)
Checks whether or not the pixel located at (x,y) is valid.boolean
isPixelWithinImageBounds(int x, int y)
boolean
isScalingApplied()
Tests whether scaling of raw raster data values is applied before they are returned as geophysically meaningful pixel values.boolean
isSourceImageSet()
Returns whether the source image is set on thisRasterDataNode
.boolean
isStxSet()
boolean
isValidMaskImageSet()
Returns whether the valid mask image is set on thisRasterDataNode
.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.boolean
isValidMaskUsed()
Tests whether or not this raster data node uses a data-mask in order to determine valid pixels.void
loadRasterData()
void
loadRasterData(ProgressMonitor pm)
Loads the raster data for thisRasterDataNode
.void
processRasterData(String message, RasterDataNode.RasterDataProcessor processor, ProgressMonitor pm)
Processes the raster's data.void
quantizeRasterData(double newMin, double newMax, double gamma, byte[] samples, int offset, int stride, ProgressMonitor pm)
byte[]
quantizeRasterData(double newMin, double newMax, double gamma, ProgressMonitor pm)
double[]
readPixels(int x, int y, int w, int h, double[] pixels)
abstract double[]
readPixels(int x, int y, int w, int h, double[] pixels, ProgressMonitor pm)
Retrieves the band data at the given offset (x, y), width and height as int data.float[]
readPixels(int x, int y, int w, int h, float[] pixels)
abstract float[]
readPixels(int x, int y, int w, int h, float[] pixels, ProgressMonitor pm)
Retrieves the band data at the given offset (x, y), width and height as int data.int[]
readPixels(int x, int y, int w, int h, int[] pixels)
abstract int[]
readPixels(int x, int y, int w, int h, int[] pixels, ProgressMonitor pm)
Retrieves the band data at the given offset (x, y), width and height as int data.void
readRasterData(int offsetX, int offsetY, int width, int height, ProductData rasterData)
Reads raster data from the node's associated data source into the given data buffer.abstract void
readRasterData(int offsetX, int offsetY, int width, int height, ProductData rasterData, ProgressMonitor pm)
The method behaves exactly asreadRasterData(int, int, int, int, ProductData)
, but clients can additionally pass aProgressMonitor
.void
readRasterDataFully()
abstract void
readRasterDataFully(ProgressMonitor pm)
Reads the complete underlying raster data.boolean[]
readValidMask(int x, int y, int w, int h, boolean[] validMask)
Reads the valid mask values for the specified area.void
removeAncillaryVariable(RasterDataNode variable)
Removes an associated ancillary variable.void
removeCachedImageData()
void
resetValidMask()
Resets the valid mask of this raster.double
scale(double v)
Applies the scalingv * scalingFactor + scalingOffset
the given input value.double
scaleInverse(double v)
Applies the inverse scaling(v - scalingOffset) / scalingFactor
the given input value.void
setAncillaryRelations(String... relations)
Sets the names of an ancillary relations to another raster data node.void
setGeoCoding(GeoCoding geoCoding)
Sets the geo-coding for thisRasterDataNode
.void
setGeophysicalNoDataValue(double noDataValue)
Sets the geophysical no-data value which is simply the scaled "raw" no-data value returned bygetNoDataValue()
.void
setImageInfo(ImageInfo imageInfo)
Sets the image information for image display.protected void
setImageInfo(ImageInfo imageInfo, boolean change)
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.void
setLog10Scaled(boolean log10Scaled)
Sets whether or not theProductData
of this band has a negative binomial distribution and thus the common logarithm (base 10) of the values is stored in the raw data.void
setModelToSceneTransform(MathTransform2D modelToSceneTransform)
Sets aMathTransform2D
from the local model CRS of thisRasterDataNode
to aProduct
's scene coordinate reference system.void
setModified(boolean modified)
Sets this node's modified flag.void
setNoDataValue(double noDataValue)
Sets the no-data value as a primitivedouble
.void
setNoDataValueUsed(boolean noDataValueUsed)
Sets whether or not the no-data value is used.abstract void
setPixelDouble(int x, int y, double pixelValue)
Sets the pixel located at (x,y) to the given double value.abstract void
setPixelFloat(int x, int y, float pixelValue)
Sets the pixel located at (x,y) to the given float value.abstract void
setPixelInt(int x, int y, int pixelValue)
Sets the pixel located at (x,y) to the given integer value.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.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.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.void
setRasterData(ProductData rasterData)
Sets the raster data of this dataset.void
setScalingFactor(double scalingFactor)
Sets the scaling factor which is applied to rawProductData
.void
setScalingOffset(double scalingOffset)
Sets the scaling offset which is applied to rawProductData
.void
setSceneToModelTransform(MathTransform2D sceneToModelTransform)
Sets aMathTransform2D
from aProduct
's scene coordinate reference system to the local model CRS of thisRasterDataNode
.void
setSourceImage(MultiLevelImage sourceImage)
Sets the source image associated with thisRasterDataNode
.void
setSourceImage(RenderedImage sourceImage)
Sets the source image associated with thisRasterDataNode
.void
setStx(Stx stx)
Sets the statistics.void
setTimeCoding(TimeCoding timeCoding)
Sets the time-coding for thisRasterDataNode
.void
setValidPixelExpression(String validPixelExpression)
Sets the expression that is used to determine whether a pixel is valid or not.void
unloadRasterData()
Un-loads the raster data for thisRasterDataNode
.void
updateExpression(String oldExternalName, String newExternalName)
Asks a product node to replace all occurences of and references to the node name given byoldExternalName
witholdExternalName
.void
writePixels(int x, int y, int w, int h, double[] pixels)
abstract void
writePixels(int x, int y, int w, int h, double[] pixels, ProgressMonitor pm)
Writes the range of given pixels specified to the specified coordinates as doubles.void
writePixels(int x, int y, int w, int h, float[] pixels)
abstract void
writePixels(int x, int y, int w, int h, float[] pixels, ProgressMonitor pm)
Writes the range of given pixels specified to the specified coordinates as floats.void
writePixels(int x, int y, int w, int h, int[] pixels)
abstract void
writePixels(int x, int y, int w, int h, int[] pixels, ProgressMonitor pm)
Writes the range of given pixels specified to the specified coordinates as integers.void
writeRasterData(int offsetX, int offsetY, int width, int height, ProductData rasterData)
abstract void
writeRasterData(int offsetX, int offsetY, int width, int height, ProductData rasterData, ProgressMonitor pm)
Writes data from this product raster into the specified region of the user-supplied raster.void
writeRasterDataFully()
abstract void
writeRasterDataFully(ProgressMonitor pm)
Writes the complete underlying raster data.-
Methods inherited from class org.esa.snap.core.datamodel.DataNode
checkDataCompatibility, createCompatibleProductData, fireProductNodeDataChanged, getData, getDataElems, getDataElemSize, getDataType, getNumDataElems, getRawStorageSize, getUnit, isReadOnly, isSynthetic, setData, setDataElems, setReadOnly, setSynthetic, setUnit
-
Methods inherited from class org.esa.snap.core.datamodel.ProductNode
fireProductNodeChanged, fireProductNodeChanged, getDescription, getDisplayName, getName, getOwner, getProduct, getProductReader, getProductReaderSafe, getProductRefString, getProductSafe, getProductWriter, getProductWriterSafe, getRawStorageSize, isModified, isPartOfSubset, isValidNodeName, removeFromFile, setDescription, setName, setOwner, toString
-
Methods inherited from class com.bc.ceres.core.ExtensibleObject
getExtension
-
-
-
-
Field Detail
-
PROPERTY_NAME_IMAGE_INFO
public static final String PROPERTY_NAME_IMAGE_INFO
- See Also:
- Constant Field Values
-
PROPERTY_NAME_LOG_10_SCALED
public static final String PROPERTY_NAME_LOG_10_SCALED
- See Also:
- Constant Field Values
-
PROPERTY_NAME_SCALING_FACTOR
public static final String PROPERTY_NAME_SCALING_FACTOR
- See Also:
- Constant Field Values
-
PROPERTY_NAME_SCALING_OFFSET
public static final String PROPERTY_NAME_SCALING_OFFSET
- See Also:
- Constant Field Values
-
PROPERTY_NAME_NO_DATA_VALUE
public static final String PROPERTY_NAME_NO_DATA_VALUE
- See Also:
- Constant Field Values
-
PROPERTY_NAME_NO_DATA_VALUE_USED
public static final String PROPERTY_NAME_NO_DATA_VALUE_USED
- See Also:
- Constant Field Values
-
PROPERTY_NAME_VALID_PIXEL_EXPRESSION
public static final String PROPERTY_NAME_VALID_PIXEL_EXPRESSION
- See Also:
- Constant Field Values
-
PROPERTY_NAME_GEO_CODING
public static final String PROPERTY_NAME_GEO_CODING
- See Also:
- Constant Field Values
-
PROPERTY_NAME_TIME_CODING
public static final String PROPERTY_NAME_TIME_CODING
- See Also:
- Constant Field Values
-
PROPERTY_NAME_STX
public static final String PROPERTY_NAME_STX
- See Also:
- Constant Field Values
-
PROPERTY_NAME_ANCILLARY_VARIABLES
public static final String PROPERTY_NAME_ANCILLARY_VARIABLES
- See Also:
- Constant Field Values
-
PROPERTY_NAME_ANCILLARY_RELATIONS
public static final String PROPERTY_NAME_ANCILLARY_RELATIONS
- See Also:
- Constant Field Values
-
PROPERTY_NAME_IMAGE_TO_MODEL_TRANSFORM
public static final String PROPERTY_NAME_IMAGE_TO_MODEL_TRANSFORM
- See Also:
- Constant Field Values
-
PROPERTY_NAME_MODEL_TO_SCENE_TRANSFORM
public static final String PROPERTY_NAME_MODEL_TO_SCENE_TRANSFORM
- See Also:
- Constant Field Values
-
PROPERTY_NAME_SCENE_TO_MODEL_TRANSFORM
public static final String PROPERTY_NAME_SCENE_TO_MODEL_TRANSFORM
- See Also:
- Constant Field Values
-
NO_DATA_TEXT
public static final String NO_DATA_TEXT
Text returned by the
method if no data is available at the given pixel position.getPixelString(int, int)
- See Also:
- Constant Field Values
-
INVALID_POS_TEXT
public static final String INVALID_POS_TEXT
Text returned by the
method if no data is available at the given pixel position.getPixelString(int, int)
- See Also:
- Constant Field Values
-
IO_ERROR_TEXT
public static final String IO_ERROR_TEXT
Text returned by the
method if an I/O error occurred while pixel data was reloaded.getPixelString(int, int)
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RasterDataNode
protected RasterDataNode(String name, int dataType, long numElems)
Constructs an object of typeRasterDataNode
.- Parameters:
name
- the name of the new objectdataType
- the data type used by the raster, must be one of the multipleProductData.TYPE_X
constants, with the exception ofProductData.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.
-
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 classProductNode
- Parameters:
modified
- whether or not this node is beeing marked as modified.- See Also:
Product.fireNodeChanged(org.esa.snap.core.datamodel.ProductNode, java.lang.String, java.lang.Object, java.lang.Object)
-
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
) theimage-to-model transformation
of the image pyramid's lowest level image is returned. Otherwise the transformation which has been set using thesetImageToModelTransform(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:
ProductNode.getProduct()
,Product.getSceneCRS()
,setImageToModelTransform(AffineTransform)
,getSourceImage()
,getGeoCoding()
-
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()
-
getModelToSceneTransform
public MathTransform2D getModelToSceneTransform()
Gets the transformation that transforms from localRasterDataNode
model coordinates to theProduct
'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 interfaceSceneTransformProvider
- Returns:
- The model-to-scene transformation, or
null
if no such exists. - Since:
- SNAP 2.0.3
- See Also:
Product.getSceneCRS()
,getImageToModelTransform()
-
setModelToSceneTransform
public void setModelToSceneTransform(MathTransform2D modelToSceneTransform)
Sets aMathTransform2D
from the local model CRS of thisRasterDataNode
to aProduct
'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 usingsetSceneToModelTransform()
.Only use this method when you know that the model CRS of this
RasterDataNode
is different than theProduct
's scene CRS or when you want to model a special relationship between differentRasterDataNode
's. When no transformation from local model to scene is possible, useMathTransform2D.NULL
.- Parameters:
modelToSceneTransform
- TheMathTransform2D
to convert local model coordinates to product scene coordinates- Since:
- SNAP 2.0.3
- See Also:
setSceneToModelTransform(MathTransform2D)
-
getSceneToModelTransform
public MathTransform2D getSceneToModelTransform()
Gets the transformation that transforms from theProduct
's scene coordinates to the localRasterDataNode
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 interfaceSceneTransformProvider
- Returns:
- The model-to-scene transformation
- Since:
- SNAP 2.0.3
- See Also:
Product.getSceneCRS()
,getImageToModelTransform()
-
setSceneToModelTransform
public void setSceneToModelTransform(MathTransform2D sceneToModelTransform)
Sets aMathTransform2D
from aProduct
's scene coordinate reference system to the local model CRS of thisRasterDataNode
. If the modelToSceneTransform is not the inverse of this transformor cannot be derived from it, it must be set usingsetModelToSceneTransform()
.Only use this method when you know that the model CRS of this
RasterDataNode
is different than theProduct
's scene CRS or when you want to model a special relationship between differentRasterDataNode
's. When no transformation from scene to local model is possible, useMathTransform2D.NULL
.- Parameters:
sceneToModelTransform
- TheMathTransform2D
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 thisRasterDataNode
.- Returns:
- the geo-coding, or
null
if not available.
-
setGeoCoding
public void setGeoCoding(GeoCoding geoCoding)
Sets the geo-coding for thisRasterDataNode
. Also sets the geo-coding of the parentProduct
if it has no geo-coding yet.On property change, the method calls
ProductNode.fireProductNodeChanged(String)
with the property namePROPERTY_NAME_GEO_CODING
.- Parameters:
geoCoding
- the new geo-coding- See Also:
Product.setSceneGeoCoding(GeoCoding)
-
getTimeCoding
public TimeCoding getTimeCoding()
Gets the time-coding of thisRasterDataNode
.- Returns:
- the time-coding, or
null
if not available. - Since:
- SNAP 2.0
- See Also:
Product.getSceneTimeCoding()
-
setTimeCoding
public void setTimeCoding(TimeCoding timeCoding)
Sets the time-coding for thisRasterDataNode
.- Parameters:
timeCoding
- the new time-coding- Since:
- SNAP 2.0
- See Also:
Product.setSceneTimeCoding(TimeCoding)
-
createPointing
protected Pointing createPointing()
Creates aPointing
applicable for this raster.- Returns:
- the pointing object, or null if a pointing is not available
-
getPointing
public Pointing getPointing()
Gets aPointing
if one is available for this raster. The methods callscreatePointing()
if a pointing has not been set so far or if itsGeoCoding
changed since the last creation of this raster'sPointing
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()
Returnstrue
if the pixel data contained in this band is "naturally" a floating point number type.- Overrides:
isFloatingPointType
in classDataNode
- Returns:
- true, if so
-
getGeophysicalDataType
public int getGeophysicalDataType()
Returns the geophysical data type of thisRasterDataNode
. The value returned is always one of theProductData.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 rawProductData
. The default value is1.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 rawProductData
.- Parameters:
scalingFactor
- the scaling factor- See Also:
isScalingApplied()
-
getScalingOffset
public final double getScalingOffset()
Gets the scaling offset which is applied to rawProductData
. The default value is0.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 rawProductData
.- Parameters:
scalingOffset
- the scaling offset- See Also:
isScalingApplied()
-
isLog10Scaled
public final boolean isLog10Scaled()
Gets whether or not theProductData
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 isfalse
.- Returns:
- whether or not the data is logging-10 scaled
- See Also:
isScalingApplied()
-
setLog10Scaled
public final void setLog10Scaled(boolean log10Scaled)
Sets whether or not theProductData
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()
-
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[])
andwritePixels(int, int, int, int, int[])
methods as well as thegetPixel<Type>
andsetPixel<Type>
methods such asgetPixelFloat(int, int)
* andsetPixelFloat(int, int, float)
.- Returns:
true
if a conversion is applyied to raw data samples before the are retuned.- See Also:
getScalingOffset()
,getScalingFactor()
,isLog10Scaled()
-
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 eithersetNoDataValue(double)
orsetGeophysicalNoDataValue(double)
is called.- Returns:
- true, if so
- See Also:
isNoDataValueUsed()
,setNoDataValue(double)
-
clearNoDataValue
public void clearNoDataValue()
Clears the no-data value, so thatisNoDataValueSet()
will returnfalse
.
-
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(boolean)
,isNoDataValueSet()
-
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 namePROPERTY_NAME_NO_DATA_VALUE_USED
.- Parameters:
noDataValueUsed
- true, if so- See Also:
isNoDataValueUsed()
-
getNoDataValue
public double getNoDataValue()
Gets the no-data value as a primitivedouble
.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()
-
setNoDataValue
public void setNoDataValue(double noDataValue)
Sets the no-data value as a primitivedouble
.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 namePROPERTY_NAME_NO_DATA_VALUE
.- Parameters:
noDataValue
- the no-data value. It is passed as adouble
in order to cover all other numeric types.- See Also:
getNoDataValue()
,isNoDataValueSet()
-
getGeophysicalNoDataValue
public double getGeophysicalNoDataValue()
Gets the geophysical no-data value which is simply the scaled "raw" no-data value returned bygetNoDataValue()
.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(double)
-
setGeophysicalNoDataValue
public void setGeophysicalNoDataValue(double noDataValue)
Sets the geophysical no-data value which is simply the scaled "raw" no-data value returned bygetNoDataValue()
.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 namePROPERTY_NAME_NO_DATA_VALUE
.- Parameters:
noDataValue
- the new geophysical no-data value- See Also:
setGeophysicalNoDataValue(double)
,isNoDataValueSet()
-
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 theisPixelValid(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 namePROPERTY_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 eitherisValidPixelExpressionSet()
orisNoDataValueUsed()
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 thenoDataValue
and thevalidPixelExpression
properties, if any. The method returnsnull
, 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 byoldExternalName
witholdExternalName
. Such references most often occur in band arithmetic expressions.- Overrides:
updateExpression
in classProductNode
- Parameters:
oldExternalName
- The old node name.newExternalName
- The new node name.
-
hasRasterData
public boolean hasRasterData()
Returns true if the raster data of thisRasterDataNode
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 returnsnull
.- 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() throws IOException
- Throws:
IOException
- if an I/O error occurs- See Also:
loadRasterData(com.bc.ceres.core.ProgressMonitor)
-
loadRasterData
public void loadRasterData(ProgressMonitor pm) throws IOException
Loads the raster data for thisRasterDataNode
. After this method has been called successfully,hasRasterData()
should always returntrue
andgetRasterData()
should always return a validProductData
instance with at leastgetRasterWidth()*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 thisRasterDataNode
.It is up to the implementation whether after this method has been called successfully, the
hasRasterData()
method returnsfalse
ortrue
.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.
-
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 ifvalidMaskImage
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 locationy
- 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:
isPixelValid(int, int, javax.media.jai.ROI)
,isPixelValid(int)
,setNoDataValueUsed(boolean)
,setNoDataValue(double)
,setValidPixelExpression(String)
-
getSampleInt
public int getSampleInt(int x, int y)
Gets a geo-physical sample value at the given pixel coordinate asint
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 coordinatey
- 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 asfloat
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 coordinatey
- 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 ifvalidMaskImage
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(int, int, javax.media.jai.ROI)
,isPixelValid(int, int)
,setNoDataValueUsed(boolean)
,setNoDataValue(double)
,setValidPixelExpression(String)
-
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 theisPixelValid(int, int)
method, and secondly, if the pixel is within the ROI (if any).- Parameters:
x
- the X co-ordinate of the pixel locationy
- the Y co-ordinate of the pixel locationroi
- the ROI, if null the method returnsisPixelValid(int, int)
- Returns:
true
if the pixel is valid- Throws:
ArrayIndexOutOfBoundsException
- if the co-ordinates are not in bounds- See Also:
isPixelValid(int, int)
,isPixelValid(int)
,setNoDataValueUsed(boolean)
,setNoDataValue(double)
,setValidPixelExpression(String)
,readValidMask(int, int, int, int, boolean[])
-
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
orloaded
.- Parameters:
x
- the X co-ordinate of the pixel locationy
- the Y co-ordinate of the pixel location- Returns:
- the pixel value at (x,y)
- Throws:
ArrayIndexOutOfBoundsException
- if the co-ordinates are not in boundsIllegalStateException
- 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
orloaded
.- Parameters:
x
- the X co-ordinate of the pixel locationy
- the Y co-ordinate of the pixel location- Returns:
- the pixel value at (x,y)
- Throws:
ArrayIndexOutOfBoundsException
- if the co-ordinates are not in boundsIllegalStateException
- 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
orloaded
.- Parameters:
x
- the X co-ordinate of the pixel locationy
- the Y co-ordinate of the pixel location- Returns:
- the pixel value at (x,y)
- Throws:
ArrayIndexOutOfBoundsException
- if the co-ordinates are not in boundsIllegalStateException
- 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
orloaded
.- Parameters:
x
- the X co-ordinate of the pixel locationy
- the Y co-ordinate of the pixel locationpixelValue
- the new pixel value at (x,y)- Throws:
ArrayIndexOutOfBoundsException
- if the co-ordinates are not in boundsIllegalStateException
- 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
orloaded
.- Parameters:
x
- the X co-ordinate of the pixel locationy
- the Y co-ordinate of the pixel locationpixelValue
- the new pixel value at (x,y)- Throws:
ArrayIndexOutOfBoundsException
- if the co-ordinates are not in boundsIllegalStateException
- 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
orloaded
.- Parameters:
x
- the X co-ordinate of the pixel locationy
- the Y co-ordinate of the pixel locationpixelValue
- the new pixel value at (x,y)- Throws:
ArrayIndexOutOfBoundsException
- if the co-ordinates are not in boundsIllegalStateException
- if this object has no internal data buffer
-
getPixels
public int[] getPixels(int x, int y, int w, int h, int[] pixels)
-
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
orloaded
. You can use thereadPixels(int, int, int, int, double[], ProgressMonitor)
method to read or compute pixel values without a raster data buffer.If the
pixels
array isnull
a new one will be created and returned.- Parameters:
x
- x offset into the bandy
- y offset into the bandw
- width of the pixel array to be readh
- height of the pixel array to be read.pixels
- integer array to be filled with datapm
- a 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)
-
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
orloaded
. You can use thereadPixels(int, int, int, int, double[], ProgressMonitor)
method to read or compute pixel values without a raster data buffer.If the
pixels
array isnull
a new one will be created and returned.- Parameters:
x
- x offset into the bandy
- y offset into the bandw
- width of the pixel array to be readh
- height of the pixel array to be read.pixels
- float array to be filled with datapm
- a 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
orloaded
. You can use thereadPixels(int, int, int, int, double[], ProgressMonitor)
method to read or compute pixel values without a raster data buffer.If the
pixels
array isnull
a new one will be created and returned.- Parameters:
x
- x offset into the bandy
- y offset into the bandw
- width of the pixel array to be readh
- height of the pixel array to be read.pixels
- double array to be filled with datapm
- a monitor to inform the user about progress- Throws:
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
orloaded
. You can use thewritePixels(int, int, int, int, double[], ProgressMonitor)
method to write pixels directly to the associatedproduct writer
.- Parameters:
x
- x offset into the bandy
- y offset into the bandw
- width of the pixel array to be writtenh
- height of the pixel array to be written.pixels
- integer array to be written- Throws:
NullPointerException
- if this band has no raster dataIllegalStateException
- 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
orloaded
. You can use thewritePixels(int, int, int, int, double[], ProgressMonitor)
method to write pixels directly to the associatedproduct writer
.- Parameters:
x
- x offset into the bandy
- y offset into the bandw
- width of the pixel array to be writtenh
- height of the pixel array to be written.pixels
- float array to be written- Throws:
NullPointerException
- if this band has no raster dataIllegalStateException
- 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
orloaded
. You can use thewritePixels(int, int, int, int, double[], ProgressMonitor)
method to write pixels directly to the associatedproduct writer
.- Parameters:
x
- x offset into the bandy
- y offset into the bandw
- width of the pixel array to be writtenh
- height of the pixel array to be written.pixels
- double array to be written- Throws:
NullPointerException
- if this band has no raster dataIllegalStateException
- 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(int, int, int, int, int[], ProgressMonitor)
-
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 isnull
a new one will be created and returned.- Parameters:
x
- x offset into the bandy
- y offset into the bandw
- width of the pixel array to be readh
- height of the pixel array to be readpixels
- array to be filled with datapm
- a progress monitor- Returns:
- the pixels read
- Throws:
IOException
- if an /IO error occursIllegalStateException
- if this object has no attachedproduct reader
-
readPixels
public float[] readPixels(int x, int y, int w, int h, float[] pixels) throws IOException
- Throws:
IOException
- See Also:
readPixels(int, int, int, int, float[], ProgressMonitor)
-
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 isnull
a new one will be created and returned.- Parameters:
x
- x offset into the bandy
- y offset into the bandw
- width of the pixel array to be readh
- height of the pixel array to be readpixels
- array to be filled with datapm
- a progress monitor- Returns:
- the pixels read
- Throws:
IllegalStateException
- if this object has no attachedproduct reader
IOException
-
readPixels
public double[] readPixels(int x, int y, int w, int h, double[] pixels) throws IOException
- Throws:
IOException
- See Also:
readPixels(int, int, int, int, double[], ProgressMonitor)
-
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 isnull
a new one will be created and returned.- Parameters:
x
- x offset into the bandy
- y offset into the bandw
- width of the pixel array to be readh
- height of the pixel array to be readpixels
- array to be filled with datapm
- a progress monitor- Returns:
- the pixels read
- Throws:
IllegalStateException
- if this object has no attachedproduct reader
IOException
-
writePixels
public void writePixels(int x, int y, int w, int h, int[] pixels) throws IOException
- Throws:
IOException
- See Also:
writePixels(int, int, int, int, int[], ProgressMonitor)
-
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 bandy
- y offset into the bandw
- width of the pixel array to be writtenh
- height of the pixel array to be writtenpixels
- array of pixels to writepm
- a progress monitor- Throws:
IllegalStateException
- if this object has no attachedproduct 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(int, int, int, int, float[], ProgressMonitor)
-
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 bandy
- y offset into the bandw
- width of the pixel array to be writtenh
- height of the pixel array to be writtenpixels
- array of pixels to writepm
- a progress monitor- Throws:
IllegalStateException
- if this object has no attachedproduct 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(int, int, int, int, double[], ProgressMonitor)
-
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 bandy
- y offset into the bandw
- width of the pixel array to be writtenh
- height of the pixel array to be writtenpixels
- array of pixels to writepm
- a progress monitor- Throws:
IllegalStateException
- if this object has no attachedproduct 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 thegetValidMaskImage()
. For a single pixel it is also possible to usisPixelValid(int, int)
- Parameters:
x
- x offset into the bandy
- y offset into the bandw
- width of the pixel array to be writtenh
- height of the pixel array to be writtenvalidMask
- mask for the specified area if the pixels are valid. Can benull
, 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 void readRasterDataFully() throws IOException
- Throws:
IOException
- if an I/O error occurs- See Also:
readRasterDataFully(ProgressMonitor)
,unloadRasterData()
-
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 returntrue
andgetRasterData()
should always return a validProductData
instance with at leastgetRasterWidth()*getRasterHeight()
elements (samples).In opposite to the
loadRasterData
method, thereadRasterDataFully
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 startsoffsetY
- the Y-offset in the raster co-ordinates where reading startswidth
- the width of the raster data bufferheight
- the height of the raster data bufferrasterData
- a raster data buffer receiving the pixels to be read- Throws:
IOException
- if an I/O error occursIllegalArgumentException
- if the raster is nullIllegalStateException
- 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 asreadRasterData(int, int, int, int, ProductData)
, but clients can additionally pass aProgressMonitor
.- Parameters:
offsetX
- the X-offset in the raster co-ordinates where reading startsoffsetY
- the Y-offset in the raster co-ordinates where reading startswidth
- the width of the raster data bufferheight
- the height of the raster data bufferrasterData
- a raster data buffer receiving the pixels to be readpm
- a monitor to inform the user about progress- Throws:
IOException
- if an I/O error occursIllegalArgumentException
- if the raster is nullIllegalStateException
- 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:
rasterData
- a raster data buffer receiving the pixels to be readoffsetX
- the X-offset in raster co-ordinates where reading startsoffsetY
- the Y-offset in raster co-ordinates where reading startswidth
- the width of the raster data bufferheight
- the height of the raster data bufferpm
- a monitor to inform the user about progress- Throws:
IOException
- if an I/O error occursIllegalArgumentException
- if the raster is nullIllegalStateException
- 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 exactlygetRasterWidth()*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 exactlygetBandOutputRasterWidth()*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 exactlywidth*height
elements of a compatible data type.- Parameters:
width
- the width of the raster data to be createdheight
- 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 dataw
- the raster widthh
- the raster height- Returns:
true
if so
-
checkCompatibleRasterData
public void checkCompatibleRasterData(ProductData rasterData, int w, int h)
Throws anIllegalArgumentException
if the given parameters dont specify a compatible raster.- Parameters:
rasterData
- the raster dataw
- the raster widthh
- 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 classDataNode
- Parameters:
visitor
- the visitor, must not benull
-
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 benull
-
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)
-
getImageInfo
public final ImageInfo getImageInfo(double[] histoSkipAreas, ProgressMonitor pm)
Gets the image creation information.If no image information has been assigned before, the
method is called with the given parameters passed to this method.createDefaultImageInfo(double[], com.bc.ceres.core.ProgressMonitor)
- Parameters:
histoSkipAreas
- Only used, if new image info is created (see
method).createDefaultImageInfo(double[], com.bc.ceres.core.ProgressMonitor)
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 benull
, 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 benull
, 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 returnsProductUtils.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 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 scalingv * scalingFactor + scalingOffset
the given input value. If thelog10Scaled
property is true, the result is taken to the power of 10 after the actual scaling.
-
scaleInverse
public final double scaleInverse(double v)
Applies the inverse scaling(v - scalingOffset) / scalingFactor
the given input value. If thelog10Scaled
property is true, the common logarithm is applied to the input before the actual scaling.- Specified by:
scaleInverse
in interfaceScaling
- 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 locationy
- 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 thisRasterDataNode
.- Returns:
- whether the source image is set.
- Since:
- BEAM 4.5
- See Also:
getSourceImage()
,setSourceImage(java.awt.image.RenderedImage)
,setSourceImage(com.bc.ceres.glevel.MultiLevelImage)
,createSourceImage()
-
getSourceImage
public MultiLevelImage getSourceImage()
Gets the source image associated with thisRasterDataNode
.- Returns:
- The source image. Never
null
. In the case thatisSourceImageSet()
returnsfalse
, the methodcreateSourceImage()
will be called in order to set and return a valid source image. - Since:
- BEAM 4.2
- See Also:
createSourceImage()
,isSourceImageSet()
-
createSourceImage
protected abstract RenderedImage createSourceImage()
Creates the source image associated with thisRasterDataNode
. This shall preferably be aMultiLevelImage
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 thisRasterDataNode
.- Parameters:
sourceImage
- The source image. Can benull
. If so,isSourceImageSet()
will returnfalse
.- Since:
- BEAM 4.2
-
setSourceImage
public void setSourceImage(MultiLevelImage sourceImage)
Sets the source image associated with thisRasterDataNode
.- Parameters:
sourceImage
- The source image. Can benull
. If so,isSourceImageSet()
will returnfalse
.- Since:
- BEAM 4.6
-
isGeophysicalImageSet
public boolean isGeophysicalImageSet()
Returns whether the geophysical image is set on thisRasterDataNode
.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 usingcreateMultiLevelModel()
.- Returns:
- The multi-level image (image pyramid) model
- See Also:
createMultiLevelModel()
-
createMultiLevelModel
public MultiLevelModel createMultiLevelModel()
Create a multi-level image model suited for source and geo-physical images returned by thisRasterDataNode
- Returns:
- A new suitable multi-level image (image pyramid) model
- See Also:
getMultiLevelModel()
,Product.createMultiLevelModel()
-
isValidMaskImageSet
public boolean isValidMaskImageSet()
Returns whether the valid mask image is set on thisRasterDataNode
.- Returns:
- Whether the source image is set.
- Since:
- BEAM 4.5
-
getValidMaskImage
public MultiLevelImage getValidMaskImage()
Gets the valid-mask image associated with thisRasterDataNode
. The image is based on thegetValidMaskExpression()
- 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(boolean, com.bc.ceres.core.ProgressMonitor)
,setStx(Stx)
-
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 monitorpm
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 thisRasterDataNode
's raster data. The method fires a property change event for the propertyPROPERTY_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 returnsnull
, 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"
, ornull
(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"
, ornull
(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"
, ornull
(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:
addAncillaryVariable(RasterDataNode, String...)
,removeAncillaryVariable(RasterDataNode)
,getAncillaryVariable(String...)
-
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:
addAncillaryVariable(RasterDataNode, String...)
,getAncillaryVariable(String...)
-
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 aSingleBandedOpImage
instead.- Parameters:
message
- a task descriptionprocessor
- the raster processorpm
- a progress monitor- Throws:
IOException
-
-