es.unex.sextante.dataObjects
Class AbstractRasterLayer

java.lang.Object
  extended by es.unex.sextante.dataObjects.AbstractRasterLayer
All Implemented Interfaces:
IDataObject, ILayer, IRasterLayer

public abstract class AbstractRasterLayer
extends java.lang.Object
implements IRasterLayer

A convenience class which implements some of the methods of the IRasterLayer interface. Extending this class is recommended instead of implementing the interface directly

Author:
volaya

Field Summary
 
Fields inherited from interface es.unex.sextante.dataObjects.IRasterLayer
INTERPOLATION_BicubicSpline, INTERPOLATION_Bilinear, INTERPOLATION_BSpline, INTERPOLATION_InverseDistance, INTERPOLATION_NearestNeighbour, RASTER_DATA_TYPE_BYTE, RASTER_DATA_TYPE_DOUBLE, RASTER_DATA_TYPE_FLOAT, RASTER_DATA_TYPE_INT, RASTER_DATA_TYPE_SHORT
 
Constructor Summary
AbstractRasterLayer()
           
 
Method Summary
 void add(IRasterLayer driver)
          adds the value of another raster layer to this one.
 void addToCellValue(int x, int y, double dValue)
          Adds a value to the current value of a cell in the first band of the layer in the first band of the layer
 void addToCellValue(int x, int y, int iBand, double dValue)
          Adds a value to the current value of a cell
 void assign(double dValue)
           
 void assign(IRasterLayer layer)
           
 void assignNoData()
           
 int[] getAccumulatedHistogram()
           
 int[] getAccumulatedHistogram(int iBand)
           
 double getAspect(int x, int y)
           
 java.lang.Object getBaseDataObject()
          Returns the base data object (i.e. the object that this class wraps, which contains the data itself)
 byte getCellValueAsByte(int x, int y)
           
 byte getCellValueAsByte(int x, int y, int band)
           
 double getCellValueAsDouble(int x, int y)
           
 double getCellValueAsDouble(int x, int y, int band)
           
 float getCellValueAsFloat(int x, int y)
           
 float getCellValueAsFloat(int x, int y, int band)
           
 int getCellValueAsInt(int x, int y)
           
 int getCellValueAsInt(int x, int y, int band)
           
 short getCellValueAsShort(int x, int y)
           
 short getCellValueAsShort(int x, int y, int band)
           
 int getDirToNextDownslopeCell(int x, int y)
           
 int getDirToNextDownslopeCell(int x, int y, boolean bForceDirToNoDataCell)
           
 double getDistToNeighborInDir(int iDir)
           
 int[] getHistogram()
          Returns the histogram of the first band of this layer
 int[] getHistogram(int iBand)
          Returns a histogram of a given band of this layer
 double getMaxValue()
          Returns the max value in the first band of the layer
 double getMaxValue(int iBand)
          Returns the max value in the given band of the layer
 double getMeanValue()
          Returns the mean value in the first band of the layer
 double getMeanValue(int iBand)
          Returns the mean value in the given band of the layer
 double getMinValue()
          Returns the min value in the first band of the layer
 double getMinValue(int iBand)
          Returns the min value in the given band of the layer
 int getNX()
          Returns the number of columns in the query window of this layer
 int getNY()
          Returns the number of rows in the query window of this layer
 double getSlope(int x, int y)
           
static double getUnitDistToNeighborInDir(int iDir)
           
 double getValueAt(double x, double y)
          Returns the value of the first band of this layer, at a given world coordinate.
 double getValueAt(double x, double y, int band)
          Returns the value at a given world coordinate.
 double getVariance()
          Returns the variance in the first band of the layer
 double getVariance(int iBand)
          Returns the variance in the given band of the layer
 double getWindowCellSize()
          Return the cellsize of the query window.
 GridExtent getWindowGridExtent()
          Returns the grid extent of the query window of this layer.
 boolean isInWindow(int x, int y)
           
 boolean isNoDataValue(double dValue)
          Checks if the given value equals the no-data value of the layer
 void multiply(double dValue)
          Multiplies all the values of a layer by a fixed value
 void setCellValue(int x, int y, double dValue)
          Sets the value at a cell, in the first band of the layer
 void setFullExtent()
          Sets the query window extent to the full extent of the layer
 void setInterpolationMethod(int iMethod)
          Sets the interpolation method to use for calculating value in points other than cell centers
 void setNoData(int x, int y)
          Set the value of a cell in the first band of a layer to the no-data value
 void setNoData(int x, int y, int iBand)
          Set the value of a cell to the no-data value
 void setWindowExtent(GridExtent extent)
          Sets a new query window extent
 void setWindowExtent(IRasterLayer layer)
          Sets the extent of the query window using the full extent of another layer
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface es.unex.sextante.dataObjects.IRasterLayer
fitToGridExtent, getBandsCount, getCellValueInLayerCoords, getDataType, getLayerCellSize, getLayerGridExtent, getNoDataValue, setCellValue, setNoDataValue
 
Methods inherited from interface es.unex.sextante.dataObjects.ILayer
getCRS, getFullExtent
 
Methods inherited from interface es.unex.sextante.dataObjects.IDataObject
close, getFilename, getName, open, postProcess, setName
 

Constructor Detail

AbstractRasterLayer

public AbstractRasterLayer()
Method Detail

getBaseDataObject

public java.lang.Object getBaseDataObject()
Description copied from interface: IDataObject
Returns the base data object (i.e. the object that this class wraps, which contains the data itself)

Specified by:
getBaseDataObject in interface IDataObject
Returns:
the base data object

setInterpolationMethod

public void setInterpolationMethod(int iMethod)
Description copied from interface: IRasterLayer
Sets the interpolation method to use for calculating value in points other than cell centers

Specified by:
setInterpolationMethod in interface IRasterLayer

getCellValueAsByte

public byte getCellValueAsByte(int x,
                               int y)
Specified by:
getCellValueAsByte in interface IRasterLayer

getCellValueAsByte

public byte getCellValueAsByte(int x,
                               int y,
                               int band)
Specified by:
getCellValueAsByte in interface IRasterLayer

getCellValueAsShort

public short getCellValueAsShort(int x,
                                 int y)
Specified by:
getCellValueAsShort in interface IRasterLayer

getCellValueAsShort

public short getCellValueAsShort(int x,
                                 int y,
                                 int band)
Specified by:
getCellValueAsShort in interface IRasterLayer

getCellValueAsInt

public int getCellValueAsInt(int x,
                             int y)
Specified by:
getCellValueAsInt in interface IRasterLayer

getCellValueAsInt

public int getCellValueAsInt(int x,
                             int y,
                             int band)
Specified by:
getCellValueAsInt in interface IRasterLayer

getCellValueAsFloat

public float getCellValueAsFloat(int x,
                                 int y)
Specified by:
getCellValueAsFloat in interface IRasterLayer

getCellValueAsFloat

public float getCellValueAsFloat(int x,
                                 int y,
                                 int band)
Specified by:
getCellValueAsFloat in interface IRasterLayer

getCellValueAsDouble

public double getCellValueAsDouble(int x,
                                   int y)
Specified by:
getCellValueAsDouble in interface IRasterLayer

getCellValueAsDouble

public double getCellValueAsDouble(int x,
                                   int y,
                                   int band)
Specified by:
getCellValueAsDouble in interface IRasterLayer

getValueAt

public double getValueAt(double x,
                         double y)
Description copied from interface: IRasterLayer
Returns the value of the first band of this layer, at a given world coordinate. The current interpolation method is used if the coordinate does not fall on the exact center of a cell.

Specified by:
getValueAt in interface IRasterLayer
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
the value at the given coordinate. If it falls outside of the layer, the current no-data value of the layer is returned

getValueAt

public double getValueAt(double x,
                         double y,
                         int band)
Description copied from interface: IRasterLayer
Returns the value at a given world coordinate. The current interpolation method is used if the coordinate does not fall on the exact center of a cell.

Specified by:
getValueAt in interface IRasterLayer
Parameters:
x - the x coordinate
y - the y coordinate
band - the band to query
Returns:
the value at the given world coordinate

isNoDataValue

public boolean isNoDataValue(double dValue)
Description copied from interface: IRasterLayer
Checks if the given value equals the no-data value of the layer

Specified by:
isNoDataValue in interface IRasterLayer
Parameters:
dValue - a value to check
Returns:
true if the given value equals the no-data value of the layer

isInWindow

public boolean isInWindow(int x,
                          int y)
Specified by:
isInWindow in interface IRasterLayer
Parameters:
x - the x coordinate(col) of the cell
y - the y coordinate(row) of the cell
Returns:
true if the given ccell is within the query window extent

getNX

public int getNX()
Description copied from interface: IRasterLayer
Returns the number of columns in the query window of this layer

Specified by:
getNX in interface IRasterLayer
Returns:
the number of columns in the query window

getNY

public int getNY()
Description copied from interface: IRasterLayer
Returns the number of rows in the query window of this layer

Specified by:
getNY in interface IRasterLayer
Returns:
the number of rows in the query window

getWindowCellSize

public double getWindowCellSize()
Description copied from interface: IRasterLayer
Return the cellsize of the query window. X and Y cellsizes are assumed to be equal

Specified by:
getWindowCellSize in interface IRasterLayer
Returns:
the cellsize of the query window

getWindowGridExtent

public GridExtent getWindowGridExtent()
Description copied from interface: IRasterLayer
Returns the grid extent of the query window of this layer. Each layer can have a query window, which makes it easier to seamlessly combine several layers.

Specified by:
getWindowGridExtent in interface IRasterLayer
Returns:
the window grid extent

assign

public void assign(double dValue)
Specified by:
assign in interface IRasterLayer

assign

public void assign(IRasterLayer layer)
Specified by:
assign in interface IRasterLayer

add

public void add(IRasterLayer driver)
Description copied from interface: IRasterLayer
adds the value of another raster layer to this one. Both layers must have the same window This is supposed to be used with monoband layers, so only the first band of each one is used.

Specified by:
add in interface IRasterLayer

assignNoData

public void assignNoData()
Specified by:
assignNoData in interface IRasterLayer

setCellValue

public void setCellValue(int x,
                         int y,
                         double dValue)
Description copied from interface: IRasterLayer
Sets the value at a cell, in the first band of the layer

Specified by:
setCellValue in interface IRasterLayer
Parameters:
x - the x coordinate (cols)
y - the y coordinate (rows)
dValue - the new value

setNoData

public void setNoData(int x,
                      int y)
Description copied from interface: IRasterLayer
Set the value of a cell in the first band of a layer to the no-data value

Specified by:
setNoData in interface IRasterLayer
Parameters:
x - the x coordinate(col) of the cell to set to no-data
y - the y coordinate(row) of the cell to set to no-data

setNoData

public void setNoData(int x,
                      int y,
                      int iBand)
Description copied from interface: IRasterLayer
Set the value of a cell to the no-data value

Specified by:
setNoData in interface IRasterLayer
Parameters:
x - the x coordinate(col) of the cell to set to no-data
y - the y coordinate(row) of the cell to set to no-data
iBand - the band to set to no-data

addToCellValue

public void addToCellValue(int x,
                           int y,
                           int iBand,
                           double dValue)
Description copied from interface: IRasterLayer
Adds a value to the current value of a cell

Specified by:
addToCellValue in interface IRasterLayer
Parameters:
x - the x coordinate (cols)
y - the y coordinate (rows)
iBand - the band (zero-based)
dValue - the value to sum

addToCellValue

public void addToCellValue(int x,
                           int y,
                           double dValue)
Description copied from interface: IRasterLayer
Adds a value to the current value of a cell in the first band of the layer in the first band of the layer

Specified by:
addToCellValue in interface IRasterLayer
Parameters:
x - the x coordinate (cols)
y - the y coordinate (rows)
dValue - the value to sum

multiply

public void multiply(double dValue)
Description copied from interface: IRasterLayer
Multiplies all the values of a layer by a fixed value

Specified by:
multiply in interface IRasterLayer
Parameters:
dValue - the value to multiply

setWindowExtent

public void setWindowExtent(IRasterLayer layer)
Description copied from interface: IRasterLayer
Sets the extent of the query window using the full extent of another layer

Specified by:
setWindowExtent in interface IRasterLayer
Parameters:
layer - the layer from which to take the extent

setWindowExtent

public void setWindowExtent(GridExtent extent)
Description copied from interface: IRasterLayer
Sets a new query window extent

Specified by:
setWindowExtent in interface IRasterLayer
Parameters:
extent - the new grid extent to set fro this layer

setFullExtent

public void setFullExtent()
Description copied from interface: IRasterLayer
Sets the query window extent to the full extent of the layer

Specified by:
setFullExtent in interface IRasterLayer

getHistogram

public int[] getHistogram(int iBand)
Description copied from interface: IRasterLayer
Returns a histogram of a given band of this layer

Specified by:
getHistogram in interface IRasterLayer
Parameters:
iBand - the index of the band (zero-based)
Returns:
a histogram of the given band of this layer

getHistogram

public int[] getHistogram()
Description copied from interface: IRasterLayer
Returns the histogram of the first band of this layer

Specified by:
getHistogram in interface IRasterLayer
Returns:
a histogram of the first band of this layer

getAccumulatedHistogram

public int[] getAccumulatedHistogram(int iBand)

getAccumulatedHistogram

public int[] getAccumulatedHistogram()
Specified by:
getAccumulatedHistogram in interface IRasterLayer

getMinValue

public double getMinValue(int iBand)
Description copied from interface: IRasterLayer
Returns the min value in the given band of the layer

Specified by:
getMinValue in interface IRasterLayer
Parameters:
iBand - the index of the band (zero-based)
Returns:
the min value of the given band of this layer

getMaxValue

public double getMaxValue(int iBand)
Description copied from interface: IRasterLayer
Returns the max value in the given band of the layer

Specified by:
getMaxValue in interface IRasterLayer
Parameters:
iBand - the index of the band (zero-based)
Returns:
the max value of the given band of this layer

getMeanValue

public double getMeanValue(int iBand)
Description copied from interface: IRasterLayer
Returns the mean value in the given band of the layer

Specified by:
getMeanValue in interface IRasterLayer
Parameters:
iBand - the index of the band (zero-based)
Returns:
the mean value of the given band of this layer

getVariance

public double getVariance(int iBand)
Description copied from interface: IRasterLayer
Returns the variance in the given band of the layer

Specified by:
getVariance in interface IRasterLayer
Parameters:
iBand - the index of the band (zero-based)
Returns:
the variance of the given band of this layer

getMeanValue

public double getMeanValue()
Description copied from interface: IRasterLayer
Returns the mean value in the first band of the layer

Specified by:
getMeanValue in interface IRasterLayer
Returns:
the mean value of the first band of this layer

getMinValue

public double getMinValue()
Description copied from interface: IRasterLayer
Returns the min value in the first band of the layer

Specified by:
getMinValue in interface IRasterLayer
Returns:
the min value of the first band of this layer

getMaxValue

public double getMaxValue()
Description copied from interface: IRasterLayer
Returns the max value in the first band of the layer

Specified by:
getMaxValue in interface IRasterLayer
Returns:
the max value of the first band of this layer

getVariance

public double getVariance()
Description copied from interface: IRasterLayer
Returns the variance in the first band of the layer

Specified by:
getVariance in interface IRasterLayer
Returns:
the variance of the first band of this layer

getSlope

public double getSlope(int x,
                       int y)
Specified by:
getSlope in interface IRasterLayer

getAspect

public double getAspect(int x,
                        int y)
Specified by:
getAspect in interface IRasterLayer

getDistToNeighborInDir

public double getDistToNeighborInDir(int iDir)
Specified by:
getDistToNeighborInDir in interface IRasterLayer

getUnitDistToNeighborInDir

public static double getUnitDistToNeighborInDir(int iDir)

getDirToNextDownslopeCell

public int getDirToNextDownslopeCell(int x,
                                     int y)
Specified by:
getDirToNextDownslopeCell in interface IRasterLayer

getDirToNextDownslopeCell

public int getDirToNextDownslopeCell(int x,
                                     int y,
                                     boolean bForceDirToNoDataCell)
Specified by:
getDirToNextDownslopeCell in interface IRasterLayer

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object