public class GridFileReader extends Object implements Closeable
Because grids can be quite large, there may be an advantage to reading only part of the grid into memory. A future version of this class may include access methods for reading the grid a row at a time.
The ASCII grid file format was created by Esri, Inc. and is widely documented on the web. However, an official description of the format was never released to the public. Therefore most information about the format has been obtained through inspection by various developers.
Development Note: The ASCII grid format supports two approaches to grid geometry depending on whether the specified coordinates for the lower-left corner indicate the center of the cell or the edge of the cell (e.g. cell-center or cell-corner representations). The Tinfour implementation of the cell-center approach has been verified using independent software applications. The implementation of the cell-corner approach has not been independently verified. The Tinfour project welcomes the assistance of anyone with resources to perform further testing and verification of this class and the GridSpecification class.
Constructor and Description |
---|
GridFileReader(File file)
Opens the specified file, reads the grid specification header, and prepares
to read the grid.
|
GridFileReader(InputStream input)
Reads the grid specification header, from the specified input stream and
prepares to read the grid.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
GridSpecification |
getGridSpecification()
Gets the specification read from the file header.
|
double[][] |
readGrid()
Reads the grid portion of the file.
|
public GridFileReader(File file) throws IOException
file
- a valid file referenceIOException
- in the event of an unrecoverable I/O condition or
file-format errorpublic GridFileReader(InputStream input) throws IOException
Performance note: It is strongly advised that the specified input stream include some kind of buffering to ensure efficient operations. For example, if the input is a Java FileInputStream, it should be wrapped in a Java BufferedInputStream.
input
- a valid input stream positioned to the start of the ASCII file
header.IOException
- in the event of an unrecoverable I/O condition or
file-format errorpublic GridSpecification getGridSpecification()
public double[][] readGrid() throws IOException
IOException
- in the event of an unrecoverable I/O condition or
file-format errorpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2021. All rights reserved.