jwo.landserf.process.io
Class BinRasterIO

java.lang.Object
  extended by jwo.landserf.process.io.FileIO
      extended by jwo.landserf.process.io.BinRasterIO

public class BinRasterIO
extends FileIO

Contains a collection of static methods for reading and writing binary raster files.

Version:
2.3, 19th April, 2007.
Author:
Jo Wood

Field Summary
 
Fields inherited from class jwo.landserf.process.io.FileIO
BIG_ENDIAN, bitsPerValue, byteOrder, DEBUG, errorMessage, filePointer, GATHER_INFO, lineNumber, LITTLE_ENDIAN, LOAD_ALL, LOAD_SELECTED, nullCode, substituteNull, useMultiplier, zMultiplier
 
Constructor Summary
BinRasterIO()
          There should be no need to call the constructor explicitly since all methods are static.
 
Method Summary
static Footprint readGeoW(String rasterFileName, int rasterHeight)
          Reads a world file containing the affine transformation that adds georeferencing to a raster file.
static Projection readProjection(String fileName)
          Creates a projection object based on a 'prj' file.
static RasterMap readRaster(String fileName, int fileFormat, GISFrame gisFrame, LSThread lsThread)
          Reads a binary file in the given format and creates a raster map from it.
static boolean writeGeoW(String rasterFileName, Footprint bounds, float xRes, float yRes)
          Writes a 'world' file containing the affine transformation that adds georeferencing to a binary raster or image file.
static boolean writeRaster(RasterMap raster, String fileName, int fileFormat, GISFrame gisFrame, LSThread lsThread)
          Writes a binary file in the given format based on the given raster map.
static boolean writeRaster(RasterMap raster, String fileName, int fileFormat, int byteOrder, int wordSize, GISFrame gisFrame, LSThread lsThread)
          Writes a binary file in the given format based on the given raster map.
 
Methods inherited from class jwo.landserf.process.io.FileIO
debug, getErrorMessage, readByte, readByte, readCharacters, readCharacters, readCharactersInLine, readDouble, readDouble, readDoubleBigEndian, readDoubleBigEndian, readDoubleLittleEndian, readDoubleLittleEndian, readFloat, readFloat, readFloatBigEndian, readFloatBigEndian, readFloatLittleEndian, readFloatLittleEndian, readInt, readInt, readIntBigEndian, readIntBigEndian, readIntLittleEndian, readIntLittleEndian, readNextWord, readNextWord, readShort, readShort, readShortBigEndian, readShortBigEndian, readShortLittleEndian, readShortLittleEndian, readUnsignedByte, readUnsignedByte, reset, seek, skip, skip, writeByte, writeCharacters, writeDouble, writeDoubleBigEndian, writeDoubleLittleEndian, writeFloat, writeFloatBigEndian, writeFloatLittleEndian, writeInt, writeIntBigEndian, writeIntLittleEndian, writeLine, writeShort, writeShortBigEndian, writeShortLittleEndian
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinRasterIO

public BinRasterIO()
There should be no need to call the constructor explicitly since all methods are static.

Method Detail

readRaster

public static RasterMap readRaster(String fileName,
                                   int fileFormat,
                                   GISFrame gisFrame,
                                   LSThread lsThread)
Reads a binary file in the given format and creates a raster map from it.

Parameters:
fileName - Name of file to read.
fileFormat - Type of binary file to read (see FileHandler).
gisFrame - GUI in which to report results.
lsThread - Thread that called this method (allows this to be interrupted).
Returns:
Raster map containing read data, or null if problems reading.
See Also:
FileHandler

writeRaster

public static boolean writeRaster(RasterMap raster,
                                  String fileName,
                                  int fileFormat,
                                  GISFrame gisFrame,
                                  LSThread lsThread)
Writes a binary file in the given format based on the given raster map. This version will ask the user via a GUI for the binary file options if format is FileHandler.BIN_R. To avoid the GUI query window call this method with the byte order and word size as parameters.

Parameters:
raster - Raster map to write out as file.
fileName - Name of file to write.
fileFormat - Type of binary file to write (see FileHandler).
gisFrame - GUI in which to report results.
lsThread - Thread that called this method (allows this to be interrupted). Can be null, in which case, method cannot be interrupted.
Returns:
True if file written successfully.
See Also:
FileHandler

writeRaster

public static boolean writeRaster(RasterMap raster,
                                  String fileName,
                                  int fileFormat,
                                  int byteOrder,
                                  int wordSize,
                                  GISFrame gisFrame,
                                  LSThread lsThread)
Writes a binary file in the given format based on the given raster map.

Parameters:
raster - Raster map to write out as file.
fileName - Name of file to write.
fileFormat - Type of binary file to write (see FileHandler).
byteOrder - If fileFormat is FileHandler.BIN_R, this should be either BIG_ENDIAN or LITTLE_ENDIAN.
wordSize - If fileFormat is FileHandler.BIN_R, this indicates the number of bytes per cell. If zero, a GUI query window will request byte order and word size from user.
gisFrame - GUI in which to report results.
lsThread - Thread that called this method (allows this to be interrupted). Can be null, in which case, method cannot be interrupted.
Returns:
True if file written successfully.
See Also:
FileHandler

readGeoW

public static Footprint readGeoW(String rasterFileName,
                                 int rasterHeight)
Reads a world file containing the affine transformation that adds georeferencing to a raster file. This is used by ArcGIS when generating binary rasters such as .bil or .tif files. It has also become a de facto standard for attaching geographic metadata to arbitrary raster files. The file name should be the same as the file to transform, with the same first and last letters as the extension, with 'w' appended to it. For example, image.tif would be associated with image.tfw, map.bil would be associated with map.blw.

Parameters:
rasterFileName - Name of raster to georeference.
rasterHeight - Height of raster (needed to transform top-left to bottom left origin).
Returns:
Location and size of origin pixel or null if problem reading file.

writeGeoW

public static boolean writeGeoW(String rasterFileName,
                                Footprint bounds,
                                float xRes,
                                float yRes)
Writes a 'world' file containing the affine transformation that adds georeferencing to a binary raster or image file. This is used by ArcGIS when generating binary rasters such as .bil or .tif files. The file name will be the same as the binary file to transform, with the same first and last letters as the extension, with 'w' appended to it. For example, image.tif would be associated with image.tfw, would be associated with map.blw.

Parameters:
rasterFileName - Name of raster to georeference.
bounds - Georeferenced bounds used to calculate transformation.
xRes - x Resolution of single raster cell.
yRes - y Resolution of single raster cell.
Returns:
True if written successfully.

readProjection

public static Projection readProjection(String fileName)
Creates a projection object based on a 'prj' file. Note that the given filename does not have to end with a .prj extension, but this routine will look for a file with the same base and >code>.prj extension. Presently only supports a limited set of projection types. If the projection information is not supported, null is returned.

Parameters:
fileName - Name of file associated with projection (the name without extension is used to find .prj file name).
Returns:
Projection information or null if none found.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009