Package hec.heclib.grid
Class FlatGrid
java.lang.Object
hec.heclib.grid.FlatGrid
FlatGrid.java
The FlatGrid class is used for conversions between DSS gridded records
and Arc/Info grids through ASCII and .flt files.
The flat grid contains data and a minimum of descriptive information.
The data is stored in a one-dimensional array of HecDoubles. The
1-D array maps to the 2-D grid the same way that DSS gridded data
does, i.e. proceeding by row from the lower left corner. Thus, the
array 1, 2, 3, 4, 5, 6, 7, 8, 9 maps to a 3x3 grid as
-------
|7|8|9|
|4|5|6|
|1|2|3|
-------
The member function setCellValue(i, j, x) inserts the value x
into the grid at the ith column in the jth row, with numbering
starting at 1, 1 in the lower left cell.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintfromAscii(BufferedReader inFile) fromAscii Member function populates a flat grid object from an Arc/Info ASCII grid file.intfromBil(BufferedReader hdrReader, BufferedInputStream fltStream) fromBil Member function populates a flat grid object from an Arc/Info binary-interleave by line image file.intfromFlt(BufferedReader hdrReader, BufferedInputStream fltStream) fromFlt Member function populates a flat grid object from an Arc/Info floating-point grid file.doubledoublegetCellValue(int col, int row) doubledoubleintintintintvoidsetCellSize(double size) voidsetData(double[] data) voidsetData(float[] data) voidsetGridSize(int ncols, int nrows) voidsetOriginCoords(double xCoord, double yCoord) voidsetOriginIndices(int i, int j) inttoAscii(BufferedWriter outFile) inttoAscii(BufferedWriter outFile, int precision) toAscii function writes a flat grid object to an Arc/Info ASCII grid file.inttoFlt(BufferedWriter hdrWriter, BufferedOutputStream fltStream) toFlt function writes a flat grid object to an Arc/Info ASCII grid file.
-
Constructor Details
-
FlatGrid
public FlatGrid() -
FlatGrid
public FlatGrid(int ncols, int nrows)
-
-
Method Details
-
fromAscii
fromAscii Member function populates a flat grid object from an Arc/Info ASCII grid file. -
fromFlt
fromFlt Member function populates a flat grid object from an Arc/Info floating-point grid file. Returns -1 for an i/o error, 1 for a data or format error; 0 for success -
fromBil
fromBil Member function populates a flat grid object from an Arc/Info binary-interleave by line image file. Returns -1 for an i/o error, 1 for a data or format error; Returns 2 for unsupported feature Returns 0 for success This method was adapted very quickly from the fromFlt method above for purposes of reading EHdr output from GDALwarp. It doesn't support all the options available in the BIL format. When it hits something it probably should support but doesn't, it returns a 2 -
toAscii
-
toAscii
toAscii function writes a flat grid object to an Arc/Info ASCII grid file.- Parameters:
outFile-precision-- Returns:
-
toFlt
toFlt function writes a flat grid object to an Arc/Info ASCII grid file.- Parameters:
hdrWriter- , a BufferedWriter for the .hdr filefltStream- , a BufferedOutputStream for the .flt file- Returns:
- an integer indicating status (C stlye)
-
getCellValue
public double getCellValue(int col, int row) -
setCellSize
public void setCellSize(double size) -
setGridSize
public void setGridSize(int ncols, int nrows) -
setOriginCoords
public void setOriginCoords(double xCoord, double yCoord) -
setOriginIndices
public void setOriginIndices(int i, int j) -
setData
public void setData(double[] data) -
setData
public void setData(float[] data) -
getCellSize
public double getCellSize() -
getNumberOfColumns
public int getNumberOfColumns() -
getNumberOfRows
public int getNumberOfRows() -
getMinXindex
public int getMinXindex() -
getMinYindex
public int getMinYindex() -
getLLXcoord
public double getLLXcoord() -
getLLYcoord
public double getLLYcoord()
-