Class GrassBinaryRasterReadHandler
- All Implemented Interfaces:
Closeable,AutoCloseable
Reading and writing is supported.
- Since:
- 3.0
- Author:
- Andrea Antonello (www.hydrologis.com)
- See Also:
-
GrassBinaryImageReaderGrassBinaryImageReadParamGrassBinaryImageMetadata
-
Constructor Summary
ConstructorsConstructorDescriptionGrassBinaryRasterReadHandler(File cellFile) the constructor to build aGrassBinaryRasterReadHandlerusable for reading grass rasters. -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()sets the abortrequired flag to true.voidclose()closes the I/O streams.Getter for the categories.getColorRules(double[] range) Getter for the colorrules.getCrs()Reads the crs definition for the map.Getter for nativeRasterRegion.doubleGetter for the noData value.double[]getRange()intintreturns theSampleModelcompatible with theWritableRaster.booleanGetter for the abortrequired flag.voidDetermines the metadata of the raster map.readRaster(ImageReadParam param) reads a grass raster, given the read parameters.readRaster(ImageReadParam param, boolean useSubSamplingAsRequestedRowcols, boolean castDoubleToFloating, ProgressListener monitor) Reads a grass raster, adding the possibility to override subsampling.voidsetNoData(double noData) Setter for the noData value.
-
Constructor Details
-
GrassBinaryRasterReadHandler
the constructor to build aGrassBinaryRasterReadHandlerusable for reading grass rasters.- Parameters:
cellFile- the file of the raw raster data.
-
-
Method Details
-
readRaster
public WritableRaster readRaster(ImageReadParam param, boolean useSubSamplingAsRequestedRowcols, boolean castDoubleToFloating, ProgressListener monitor) throws IOException, DataFormatException Reads a grass raster, adding the possibility to override subsampling.- Parameters:
param- the read parameters.useSubSamplingAsRequestedRowcols- a flag that gives the possibility to bypass the imageio subsampling mechanism. With GRASS maps this is often more performing in some boundary situations. In the case this flag is set to true, the subsampling values will be handled as the requested columns and rows.castDoubleToFloating- a flag that gives the possibility to force the reading of a map as a floating point map. This is necessary right now because of a imageio bug: https://jai-imageio-core.dev.java.net /issues/show_bug.cgi?id=180- Returns:
- the read
raster - Throws:
IOExceptionDataFormatException
-
readRaster
reads a grass raster, given the read parameters.The data are read into a single banded, floating point
WritableRaster. ARectItercan be used to access the data afterwards.- Parameters:
param- the read parameters.- Returns:
- the read raster
- Throws:
IOExceptionDataFormatException
-
parseHeaderAndAccessoryFiles
Determines the metadata of the raster map.Reads the map type given a file and its mapset, the information from the header file in the cellhd directory and determines the geographic limits, format of the data, etc from the file. NOTE: for further informations about cell header files, read the package description.
INFO: this is a reader method.
- Throws:
IOException
-
getNativeRasterRegion
Getter for nativeRasterRegion.INFO: this is a reader method.
- Returns:
- the nativeRasterRegion.
-
getColorRules
Getter for the colorrules.INFO: this is a reader method.
- Returns:
- the list of single colorrules.
- Throws:
IOException
-
getCategories
Getter for the categories.INFO: this is a reader method.
- Returns:
- the attribute table as read in the categories file
- Throws:
IOException
-
close
closes the I/O streams.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
abort
public void abort()sets the abortrequired flag to true.As soon as possible that should abort the reader.
-
isAborting
public boolean isAborting()Getter for the abortrequired flag.- Returns:
- the abortRequired flag.
-
setNoData
public void setNoData(double noData) Setter for the noData value.- Parameters:
noData- the nodata value to set.
-
getNoData
public double getNoData()Getter for the noData value.- Returns:
- the nodata value.
-
getCrs
Reads the crs definition for the map.The definition for grass maps is held in the location. Grass projection definitions are usually in a non parsable internal format. In JGrass we ask the user to choose the CRS. If the user doesn't do so, the CRS will result to be undefined.
- Returns:
- the
CoordinateReferenceSystemfor the map. Null if it is not defined. - Throws:
IOException- if there were problems in parsing the CRS file.
-
getSampleModel
returns theSampleModelcompatible with theWritableRaster.- Returns:
- the sample model compatible with the created raster
-
getRasterMapWidth
public int getRasterMapWidth() -
getRasterMapHeight
public int getRasterMapHeight() -
getRange
public double[] getRange()
-