org.openjump.core.rasterimage.sextante
Class AbstractSextanteRasterLayer

java.lang.Object
  extended by org.openjump.core.rasterimage.sextante.AbstractSextanteRasterLayer
All Implemented Interfaces:
ISextanteDataObject, ISextanteLayer, ISextanteRasterLayer
Direct Known Subclasses:
OpenJUMPSextanteRasterLayer

public abstract class AbstractSextanteRasterLayer
extends java.lang.Object
implements ISextanteRasterLayer

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
protected  java.lang.Object m_BaseDataObject
           
 
Fields inherited from interface org.openjump.core.rasterimage.sextante.ISextanteRasterLayer
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
AbstractSextanteRasterLayer()
           
 
Method Summary
 void add(ISextanteRasterLayer 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(ISextanteRasterLayer 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(ISextanteRasterLayer 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openjump.core.rasterimage.sextante.ISextanteRasterLayer
fitToGridExtent, getBandsCount, getCellValueInLayerCoords, getDataType, getLayerCellSize, getLayerGridExtent, getNoDataValue, setCellValue, setNoDataValue
 
Methods inherited from interface org.openjump.core.rasterimage.sextante.ISextanteLayer
getCRS, getFullExtent
 
Methods inherited from interface org.openjump.core.rasterimage.sextante.ISextanteDataObject
close, getFilename, getName, open, postProcess, setName
 

Field Detail

m_BaseDataObject

protected java.lang.Object m_BaseDataObject
Constructor Detail

AbstractSextanteRasterLayer

public AbstractSextanteRasterLayer()
Method Detail

getBaseDataObject

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

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

setInterpolationMethod

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

Specified by:
setInterpolationMethod in interface ISextanteRasterLayer

getCellValueAsByte

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

getCellValueAsByte

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

getCellValueAsShort

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

getCellValueAsShort

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

getCellValueAsInt

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

getCellValueAsInt

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

getCellValueAsFloat

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

getCellValueAsFloat

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

getCellValueAsDouble

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

getCellValueAsDouble

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

getValueAt

public double getValueAt(double x,
                         double y)
Description copied from interface: ISextanteRasterLayer
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 ISextanteRasterLayer
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: ISextanteRasterLayer
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 ISextanteRasterLayer
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: ISextanteRasterLayer
Checks if the given value equals the no-data value of the layer

Specified by:
isNoDataValue in interface ISextanteRasterLayer
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 ISextanteRasterLayer
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: ISextanteRasterLayer
Returns the number of columns in the query window of this layer

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

getNY

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

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

getWindowCellSize

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

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

getWindowGridExtent

public GridExtent getWindowGridExtent()
Description copied from interface: ISextanteRasterLayer
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 ISextanteRasterLayer
Returns:
the window grid extent

assign

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

assign

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

add

public void add(ISextanteRasterLayer driver)
Description copied from interface: ISextanteRasterLayer
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 ISextanteRasterLayer

assignNoData

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

setCellValue

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

Specified by:
setCellValue in interface ISextanteRasterLayer
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: ISextanteRasterLayer
Set the value of a cell in the first band of a layer to the no-data value

Specified by:
setNoData in interface ISextanteRasterLayer
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: ISextanteRasterLayer
Set the value of a cell to the no-data value

Specified by:
setNoData in interface ISextanteRasterLayer
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: ISextanteRasterLayer
Adds a value to the current value of a cell

Specified by:
addToCellValue in interface ISextanteRasterLayer
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: ISextanteRasterLayer
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 ISextanteRasterLayer
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: ISextanteRasterLayer
Multiplies all the values of a layer by a fixed value

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

setWindowExtent

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

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

setWindowExtent

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

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

setFullExtent

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

Specified by:
setFullExtent in interface ISextanteRasterLayer

getHistogram

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

Specified by:
getHistogram in interface ISextanteRasterLayer
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: ISextanteRasterLayer
Returns the histogram of the first band of this layer

Specified by:
getHistogram in interface ISextanteRasterLayer
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 ISextanteRasterLayer

getMinValue

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

Specified by:
getMinValue in interface ISextanteRasterLayer
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: ISextanteRasterLayer
Returns the max value in the given band of the layer

Specified by:
getMaxValue in interface ISextanteRasterLayer
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: ISextanteRasterLayer
Returns the mean value in the given band of the layer

Specified by:
getMeanValue in interface ISextanteRasterLayer
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: ISextanteRasterLayer
Returns the variance in the given band of the layer

Specified by:
getVariance in interface ISextanteRasterLayer
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: ISextanteRasterLayer
Returns the mean value in the first band of the layer

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

getMinValue

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

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

getMaxValue

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

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

getVariance

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

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

getSlope

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

getAspect

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

getDistToNeighborInDir

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

getUnitDistToNeighborInDir

public static double getUnitDistToNeighborInDir(int iDir)

getDirToNextDownslopeCell

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

getDirToNextDownslopeCell

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

toString

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