Class GridCoverage

Object
BandedCoverage
GridCoverage
Direct Known Subclasses:
Buffered­Grid­Coverage, Grid­Coverage2D

public abstract class GridCoverage extends BandedCoverage
Base class of coverages with domains defined as a set of grid points. The essential property of coverage is to be able to generate a value for any point within its domain. Since a grid coverage is represented by a grid of values, the value returned by the coverage for a point is that of the grid value whose location is nearest the point.
Since:
1.0

Defined in the sis-feature module

  • Constructor Details

    • GridCoverage

      protected GridCoverage(GridGeometry domain, List<? extends SampleDimension> ranges)
      Constructs a grid coverage using the specified grid geometry and sample dimensions. The grid geometry defines the "domain" (inputs) of the coverage function, and the sample dimensions define the "range" (output) of that function.
      Parameters:
      domain - the grid extent, CRS and conversion from cell indices to CRS.
      ranges - sample dimensions for each image band.
      Throws:
      Null­Pointer­Exception - if an argument is null or if the list contains a null element.
      Illegal­Argument­Exception - if the range list is empty.
  • Method Details

    • getCoordinateReferenceSystem

      public CoordinateReferenceSystem getCoordinateReferenceSystem()
      Returns the coordinate reference system to which the values in grid domain are referenced. This is the target coordinate reference system of the grid­To­CRS math transform.

      The default implementation delegates to Grid­Geometry​.get­Coordinate­Reference­System().

      Returns:
      the "real world" CRS of this coverage.
      Throws:
      Incomplete­Grid­Geometry­Exception - if the grid geometry has no CRS.
    • getGridGeometry

      public GridGeometry getGridGeometry()
      Returns information about the domain of this grid coverage. Information includes the grid extent, CRS and conversion from cell indices to CRS. Grid­Geometry can also provide derived information like bounding box and resolution.
      Returns:
      grid extent, CRS and conversion from cell indices to CRS.
      See Also:
    • getSampleDimensions

      public List<SampleDimension> getSampleDimensions()
      Returns information about the range of this grid coverage. Information include names, sample value ranges, fill values and transfer functions for all bands in this grid coverage. The length of the returned list should be equal to the number of bands in the rendered image.
      Specified by:
      get­Sample­Dimensions in class Banded­Coverage
      Returns:
      names, value ranges, fill values and transfer functions for all bands in this grid coverage.
      See Also:
    • forConvertedValues

      public GridCoverage forConvertedValues(boolean converted)
      Returns a grid coverage that contains real values or sample values, depending if converted is true or false respectively. If there is no transfer function defined by the sample dimensions, then this method returns this. In all cases, the returned grid coverage r has the following properties:
      • The list returned by r​.get­Sample­Dimensions() is equal to the list returned by this.get­Sample­Dimensions() with each element e replaced by e.for­Converted­Values(converted).
      • The Rendered­Image produced by r​.render(extent) is equivalent to the image returned by this.render(extent) with all sample values converted using the transfer function if converted is true, or the inverse of transfer function if converted is false.
      Parameters:
      converted - true for a coverage containing converted values, or false for a coverage containing packed values.
      Returns:
      a coverage containing converted or packed values, depending on converted argument value. May be this but never null.
      See Also:
    • evaluator

      public GridEvaluator evaluator()
      Creates a new function for computing or interpolating sample values at given locations. That function accepts Direct­Position in arbitrary Coordinate Reference System; conversions to grid indices are applied as needed.

      Multi-threading

      Grid­Evaluators are not thread-safe. For computing sample values concurrently, a new Grid­Evaluator instance should be created for each thread by invoking this method multiply times.
      Specified by:
      evaluator in class Banded­Coverage
      Returns:
      a new function for computing or interpolating sample values.
      Since:
      1.1
    • render

      public abstract RenderedImage render(GridExtent sliceExtent)
      Returns a two-dimensional slice of grid data as a rendered image. The given slice­Extent argument specifies the coordinates of the slice in all dimensions that are not in the two-dimensional image. For example if this grid coverage has (x,y,z,t) dimensions and we want to render an image of data in the (x,y) dimensions, then the given slice­Extent shall contain the (z,t) coordinates of the desired slice. Those coordinates are specified in a grid extent where low coordinate = high coordinate in the z and t dimensions. The two dimensions of the data to be shown (x and y in our example) shall be the only dimensions having a size greater than 1 cell.

      If the slice­Extent argument is null, then the default value is get­Grid­Geometry().get­Extent(). This means that grid­Extent is optional for two-dimensional grid coverages or grid coverages where all dimensions except two have a size of 1 cell. If the grid extent contains more than 2 dimensions with a size greater than one cell, then a Subspace­Not­Specified­Exception is thrown.

      How to compute a slice extent from a slice point in "real world" coordinates

      The slice­Extent is specified to this method as grid indices. If the z and t values are not grid indices but are relative to some Coordinate Reference System (CRS) instead, then the slice extent can be computed as below. First, a slice point containing the z and t coordinates should be constructed as a Direct­Position in one of the following ways:
      • The slice­Point has a CRS with two dimensions less than this grid coverage CRS.
      • The slice­Point has the same CRS than this grid coverage, but the two coordinates to exclude are set to Double​.Na­N.
      Then:
      slice­Extent = get­Grid­Geometry().derive().slice(slicePoint).getIntersection();
      If the slice­Point CRS is different than this grid coverage CRS (except for the number of dimensions), a coordinate transformation will be applied as needed.

      Characteristics of the returned image

      Image dimensions x and y map to the first and second dimension respectively of the two-dimensional slice­Extent subspace. The coordinates given by Rendered­Image​.get­Min­X() and get­Min­Y() will be the image location relative to the location specified in slice­Extent low coordinates. For example in the case of image minimum X coordinate:
      • A value of 0 means that the image left border is exactly where requested by slice­Extent​.get­Low(x­Dimension).
      • A positive value means that the returned image is shifted to the right compared to specified extent. This implies that the image has less data than requested on left side. It may happen if the specified extent is partially outside grid coverage extent.
      • A negative value means that the returned image is shifted to the left compared to specified extent. This implies that the image has more data than requested on left side. It may happen if the image is tiled, the specified slice­Extent covers many tiles, and expanding the specified extent is necessary for returning an integer amount of tiles.
      Similar discussion applies to the minimum Y coordinate. The image width and height will be the slice­Extent sizes if this method can honor exactly the request, or otherwise may be adjusted for the same reasons than x and y location discussed above.

      Implementations should return a view as much as possible, without copying sample values. Grid­Coverage subclasses can use the Image­Renderer class as a helper tool for that purpose. This method does not mandate any behavior regarding tiling (size of tiles, their numbering system, etc.). Some implementations may defer data loading until a tile is requested.

      Parameters:
      slice­Extent - a subspace of this grid coverage extent where all dimensions except two have a size of 1 cell. May be null if this grid coverage has only two dimensions with a size greater than 1 cell.
      Returns:
      the grid slice as a rendered image. Image location is relative to slice­Extent.
      Throws:
      Mismatched­Dimension­Exception - if the given extent does not have the same number of dimensions than this coverage.
      Subspace­Not­Specified­Exception - if the given argument is not sufficient for reducing the grid to a two-dimensional slice.
      Disjoint­Extent­Exception - if the given extent does not intersect this grid coverage.
      Cannot­Evaluate­Exception - if this method can not produce the rendered image for another reason.
    • toString

      public String toString()
      Returns a string representation of this grid coverage for debugging purpose. The returned string is implementation dependent and may change in any future version. Current implementation is equivalent to the following, where <default flags> is the same set of flags than Grid­Geometry​.to­String().
      return toTree(Locale.getDefault(), <default flags>).toString();
      Overrides:
      to­String in class Object
      Returns:
      a string representation of this grid coverage for debugging purpose.
    • toTree

      @Debug public TreeTable toTree(Locale locale, int bitmask)
      Returns a tree representation of some elements of this grid coverage. The tree representation is for debugging purpose only and may change in any future SIS version.
      Parameters:
      locale - the locale to use for textual labels.
      bitmask - combination of Grid­Geometry flags.
      Returns:
      a tree representation of the specified elements.
      See Also: