com.moseph.gis.raster
Class Raster

java.lang.Object
  extended by com.moseph.gis.raster.Raster

public class Raster
extends java.lang.Object

Represents my best guess at the ESRI ASCII raster format. I couldn't find any sensible documentation, so it supports the following features:

Author:
dmrust

Field Summary
protected  double cellsize
           
protected  int cols
           
protected  double[][] data
           
static java.lang.String DEFAULT_NODATA
           
protected  java.lang.String NDATA
           
protected  int rows
           
protected  double xll
           
protected  double yll
           
 
Constructor Summary
Raster()
          Creates an empty raster
Raster(double[][] data, double cellsize, double xll, double yll)
          Creates a raster from the given data
Raster(double cellsize, double xll, double yll)
          Creates a raster from the given data
Raster(int[][] data, double cellsize, double xll, double yll)
          Creates a raster from the given data
 
Method Summary
 double getCellsize()
           
 int getCols()
           
 double[][] getData()
          Returns the underlying data array - NOTE: this is *NOT* a copy, if you change it, you change the data
 java.lang.String getNDATA()
           
 int getRows()
           
static Raster getTempRaster(double[][] data, double xll, double yll, double size)
           
static Raster getTempRaster(double[][] data, double xll, double yll, double size, java.lang.String ndata)
           
 double getValue(int row, int column)
           
 double getXll()
           
 double getYll()
           
 void init(Raster other)
          Sets the parameters of this raster (rows, columns, corner, cellsize, NDATA etc) to be the same as the other raster.
 void initData()
          Initialises the Raster to Double.NaN (i.e.
 void initData(double value)
          Initialises the raster so the entire data array contains 'value'
 void print()
           
 void setCellsize(double cellsize)
           
 void setData(double[][] data)
          Copies the given data into the underlying data array.
 void setData(int[][] data)
          Copies the given data into the underlying data array.
 void setNDATA(java.lang.String nDATA)
           
 void setSize(int nrows, int columns)
          Sets the size of the raster, and also initialises the array with NDATA
 void setValue(int row, int column, double value)
           
 void setXll(double xll)
           
 void setYll(double yll)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected double[][] data

xll

protected double xll

yll

protected double yll

cellsize

protected double cellsize

cols

protected int cols

rows

protected int rows

NDATA

protected java.lang.String NDATA

DEFAULT_NODATA

public static final java.lang.String DEFAULT_NODATA
See Also:
Constant Field Values
Constructor Detail

Raster

public Raster()
Creates an empty raster


Raster

public Raster(double cellsize,
              double xll,
              double yll)
Creates a raster from the given data

Parameters:
cellsize -
xll -
yll -

Raster

public Raster(double[][] data,
              double cellsize,
              double xll,
              double yll)
Creates a raster from the given data

Parameters:
data -
cellsize -
xll -
yll -

Raster

public Raster(int[][] data,
              double cellsize,
              double xll,
              double yll)
Creates a raster from the given data

Parameters:
data -
cellsize -
xll -
yll -
Method Detail

print

public void print()

getTempRaster

public static Raster getTempRaster(double[][] data,
                                   double xll,
                                   double yll,
                                   double size)

getTempRaster

public static Raster getTempRaster(double[][] data,
                                   double xll,
                                   double yll,
                                   double size,
                                   java.lang.String ndata)

init

public void init(Raster other)
Sets the parameters of this raster (rows, columns, corner, cellsize, NDATA etc) to be the same as the other raster. This includes initialising the data array with NDATAs

Parameters:
other -

initData

public void initData()
Initialises the Raster to Double.NaN (i.e. NDATA)


initData

public void initData(double value)
Initialises the raster so the entire data array contains 'value'

Parameters:
value -

getData

public double[][] getData()
Returns the underlying data array - NOTE: this is *NOT* a copy, if you change it, you change the data

Returns:
the data array

setValue

public void setValue(int row,
                     int column,
                     double value)

getValue

public double getValue(int row,
                       int column)

setData

public void setData(double[][] data)
Copies the given data into the underlying data array. Also updates the number of rows and columns.

Parameters:
data -

setData

public void setData(int[][] data)
Copies the given data into the underlying data array. Also updates the number of rows and columns.

Parameters:
data -

getXll

public double getXll()

setXll

public void setXll(double xll)

getYll

public double getYll()

setYll

public void setYll(double yll)

getCellsize

public double getCellsize()

setCellsize

public void setCellsize(double cellsize)

getCols

public int getCols()

getRows

public int getRows()

setSize

public void setSize(int nrows,
                    int columns)
Sets the size of the raster, and also initialises the array with NDATA

Parameters:
nrows -
columns -

getNDATA

public java.lang.String getNDATA()

setNDATA

public void setNDATA(java.lang.String nDATA)