Class GrassCoverageReader

All Implemented Interfaces:
GridCoverageReader, GridCoverage2DReader

public class GrassCoverageReader extends AbstractGridCoverage2DReader implements GridCoverage2DReader
Coverage Reader class for reading GRASS raster maps.

The class reads a GRASS raster map from a GRASS workspace (see package documentation for further info). The reading is really done via Imageio extended classes.

Since:
3.0
Author:
Andrea Antonello (www.hydrologis.com)
See Also:
  • Constructor Details

    • GrassCoverageReader

      public GrassCoverageReader(Object input)
      Sets the input source to use to the given file object.

      The input source must be set before any of the query or read methods are used.

      Parameters:
      input - the File to use for future decoding.
  • Method Details

    • setParams

      public void setParams(PixelInCell cellAnchor, Interpolation interpolation, boolean useSubSamplingAsColsRows, boolean castDoubleToFloating, ProgressListener monitor)
      Constructor for the GrassCoverageReader.
      Parameters:
      cellAnchor - the object defining whether to assume the pixel value to be read in the grid's cell corner or center.
      interpolation - the type of interpolation to be used in the case some scaling or padding has to be done.
      useSubSamplingAsColsRows - a flag that gives the possibility to bypass the imageio subsampling mechanism. With GRASS maps this is often more performant 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.
      monitor - a monitor for logging purposes. This can be null, in which case a dummy one will be used.
    • readRaster

      public GridCoverage2D readRaster(JGrassRegion region) throws IOException
      Performs the reading of the coverage.

      This method read the grass file with a special image I/O class. If the image support the tiling read the data with a special operation which are written for this case. The step are:

    • set the region in the world
    • set the region to read in the JAI coordinate
    • read the data directly with driver or, if isTiling is true, with the operation.
    • verify if the image cover whole the region, if not fill the rows and columns with padding (with the Border operation)
    • scale the image to return an image with the number of columns and rows equal to the requestedRegion
    • set the coverage (with the transformation from the JAI coordinate to the real world coordinate.

    • Parameters:
      region - the regionto read. If null, the map is read in its original boundary and resolution.
      Returns:
      the read coverage.
      Throws:
      IOException
    • getLegendString

      public String getLegendString()
      Getter for the legend string.
      Returns:
      the legendstring.
    • getCategoriesString

      public String getCategoriesString()
      Getter for the categories string.
      Returns:
      the categories string.
    • getRange

      public double[] getRange()
      Gets the range.

      Note that the range is available only if the raster was read once.

      Returns:
      the range non considering novalues.
    • read

      Description copied from class: AbstractGridCoverage2DReader
      Read the current grid coverage from the stream.

      Example:

       
       
       
      Specified by:
      read in interface GridCoverage2DReader
      Specified by:
      read in interface GridCoverageReader
      Specified by:
      read in class AbstractGridCoverage2DReader
      Parameters:
      params - Optional parameters matching Format.getReadParameters().
      Returns:
      a grid coverage from the input source.
      Throws:
      InvalidParameterNameException - if a parameter in parameters doesn't have a recognized name.
      InvalidParameterValueException - if a parameter in parameters doesn't have a valid value.
      ParameterNotFoundException - if a parameter was required for the operation but was not provided in the parameters list.
      IOException - if a read operation failed for some other input/output reason, including FileNotFoundException if no file with the given name can be found, or IIOException if an error was thrown by the underlying image library.
      IllegalArgumentException
    • getFormat

      public Format getFormat()
      Description copied from interface: GridCoverageReader
      Returns the format handled by this GridCoverageReader.
      Specified by:
      getFormat in interface GridCoverageReader