Class GeoTiffReader

java.lang.Object
org.geotools.coverage.grid.io.AbstractGridCoverage2DReader
org.geotools.gce.geotiff.GeoTiffReader
All Implemented Interfaces:
org.geotools.api.coverage.grid.GridCoverageReader, org.geotools.coverage.grid.io.GridCoverage2DReader

public class GeoTiffReader extends org.geotools.coverage.grid.io.AbstractGridCoverage2DReader implements org.geotools.coverage.grid.io.GridCoverage2DReader

this class is responsible for exposing the data and the Georeferencing metadata available to the Geotools library. This reader is heavily based on the capabilities provided by the ImageIO tools and JAI libraries.

Since:
2.1
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final RenderingHints.Key
    Hint to override the ImageReaderSpi used for loading TIFF data.
    static final String
    With this java switch I can control whether or not an external PRJ files takes precedence over the internal CRS definition

    Fields inherited from class org.geotools.coverage.grid.io.AbstractGridCoverage2DReader

    closeMe, coverageFactory, coverageName, crs, dtLayout, EPS, gzipped, highestRes, hints, inStream, inStreamSPI, numOverviews, offsets, originalEnvelope, originalGridRange, overViewResolutions, raster2Model, scales, source

    Fields inherited from interface org.geotools.coverage.grid.io.GridCoverage2DReader

    ELEVATION_DOMAIN, ELEVATION_DOMAIN_MAXIMUM, ELEVATION_DOMAIN_MINIMUM, ELEVATION_DOMAIN_RESOLUTION, FILE_SOURCE_PROPERTY, HAS_ELEVATION_DOMAIN, HAS_TIME_DOMAIN, MULTICRS_EPSGCODES, MULTICRS_READER, PAM_DATASET, REPROJECTING_READER, SOURCE_URL_PROPERTY, TIME_DOMAIN, TIME_DOMAIN_MAXIMUM, TIME_DOMAIN_MINIMUM, TIME_DOMAIN_RESOLUTION
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of GeoTiffReader
    GeoTiffReader(Object input, org.geotools.util.factory.Hints uHints)
    Creates a new instance of GeoTiffReader
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    checkName(String coverageName)
     
    protected final org.geotools.coverage.grid.GridCoverage2D
    createCoverage(javax.media.jai.PlanarImage image, org.geotools.api.referencing.operation.MathTransform raster2Model, javax.media.jai.ROI roi)
    Creates a GridCoverage for the provided PlanarImage using the AbstractGridCoverage2DReader.raster2Model that was provided for this coverage.
    protected List<org.geotools.api.data.FileGroupProvider.FileGroup>
     
    org.geotools.api.coverage.grid.Format
     
    int
    Number of coverages for this reader is 1
    org.geotools.coverage.grid.io.GroundControlPoints
     
    org.geotools.api.data.ResourceInfo
    getInfo(String coverageName)
     
    org.geotools.coverage.grid.io.imageio.MaskOverviewProvider
    Returns the MaskOverviewProvider used by this reader.
    org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffIIOMetadataDecoder
    Returns the geotiff metadata for this geotiff file.
    org.geotools.coverage.grid.GridCoverage2D
    read(org.geotools.api.parameter.GeneralParameterValue[] params)
    This method reads in the TIFF image, constructs an appropriate CRS, determines the math transform from raster to the CRS model, and constructs a GridCoverage.

    Methods inherited from class org.geotools.coverage.grid.io.AbstractGridCoverage2DReader

    addAllSiblings, addSiblings, collectScaleOffset, createImageCoverage, createImageCoverage, createImageCoverage, createImageCoverage, decimationOnReadingControl, dispose, finalize, getCoordinateReferenceSystem, getCoordinateReferenceSystem, getDatasetLayout, getDatasetLayout, getDynamicParameters, getDynamicParameters, getGridCoverageNames, getGroundControlPoints, getHighestRes, getHighestRes, getImageLayout, getImageLayout, getInfo, getMetadataNames, getMetadataNames, getMetadataValue, getMetadataValue, getMultiLevelROIProvider, getOriginalEnvelope, getOriginalEnvelope, getOriginalGridRange, getOriginalGridRange, getOriginalGridToWorld, getOriginalGridToWorld, getOverviewGridEnvelope, getOverviewGridEnvelope, getPamDataset, getPamDataset, getReadingResolutions, getReadingResolutions, getRescaledRasterToModel, getResolution, getResolutionLevels, getResolutionLevels, getSibling, getSource, getSourceAsFile, read, setlayout, setLayout, setReadParams, setReadParams

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.geotools.coverage.grid.io.GridCoverage2DReader

    getCoordinateReferenceSystem, getCoordinateReferenceSystem, getDatasetLayout, getDatasetLayout, getDynamicParameters, getDynamicParameters, getImageLayout, getImageLayout, getInfo, getOriginalEnvelope, getOriginalEnvelope, getOriginalGridRange, getOriginalGridRange, getOriginalGridToWorld, getOriginalGridToWorld, getReadingResolutions, getReadingResolutions, getResolutionLevels, getResolutionLevels, read

    Methods inherited from interface org.geotools.api.coverage.grid.GridCoverageReader

    dispose, getGridCoverageNames, getMetadataNames, getMetadataNames, getMetadataValue, getMetadataValue, getSource
  • Field Details

    • OVERRIDE_CRS_SWITCH

      public static final String OVERRIDE_CRS_SWITCH

      With this java switch I can control whether or not an external PRJ files takes precedence over the internal CRS definition

      See Also:
    • HINT_READER_SPI

      public static final RenderingHints.Key HINT_READER_SPI

      Hint to override the ImageReaderSpi used for loading TIFF data. Otherwise this class defaults to using the image-io-ext TIFF reader, rather than one looked up from JAI's registry, so we must use a separate mechanism to support overriding (instead of Java's pluggable services that JAI uses)

  • Constructor Details

    • GeoTiffReader

      public GeoTiffReader(Object input) throws org.geotools.api.data.DataSourceException

      Creates a new instance of GeoTiffReader

      Parameters:
      input - the GeoTiff file
      Throws:
      org.geotools.api.data.DataSourceException
    • GeoTiffReader

      public GeoTiffReader(Object input, org.geotools.util.factory.Hints uHints) throws org.geotools.api.data.DataSourceException

      Creates a new instance of GeoTiffReader

      Parameters:
      input - the GeoTiff file
      uHints - user-supplied hints TODO currently are unused
      Throws:
      org.geotools.api.data.DataSourceException
  • Method Details

    • getFormat

      public org.geotools.api.coverage.grid.Format getFormat()
      Specified by:
      getFormat in interface org.geotools.api.coverage.grid.GridCoverageReader
      See Also:
      • GridCoverageReader.getFormat()
    • getInfo

      public org.geotools.api.data.ResourceInfo getInfo(String coverageName)
      Specified by:
      getInfo in interface org.geotools.coverage.grid.io.GridCoverage2DReader
      Overrides:
      getInfo in class org.geotools.coverage.grid.io.AbstractGridCoverage2DReader
    • read

      public org.geotools.coverage.grid.GridCoverage2D read(org.geotools.api.parameter.GeneralParameterValue[] params) throws IOException

      This method reads in the TIFF image, constructs an appropriate CRS, determines the math transform from raster to the CRS model, and constructs a GridCoverage.

      Specified by:
      read in interface org.geotools.coverage.grid.io.GridCoverage2DReader
      Specified by:
      read in interface org.geotools.api.coverage.grid.GridCoverageReader
      Specified by:
      read in class org.geotools.coverage.grid.io.AbstractGridCoverage2DReader
      Parameters:
      params - currently ignored, potentially may be used for hints.
      Returns:
      grid coverage represented by the image
      Throws:
      IOException - on any IO related troubles
    • getMetadata

      public org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffIIOMetadataDecoder getMetadata()

      Returns the geotiff metadata for this geotiff file.

      Returns:
      the metadata
    • createCoverage

      protected final org.geotools.coverage.grid.GridCoverage2D createCoverage(javax.media.jai.PlanarImage image, org.geotools.api.referencing.operation.MathTransform raster2Model, javax.media.jai.ROI roi) throws IOException

      Creates a GridCoverage for the provided PlanarImage using the AbstractGridCoverage2DReader.raster2Model that was provided for this coverage.

      This method is vital when working with coverages that have a raster to model transformation that is not a simple scale and translate.

      Parameters:
      image - contains the data for the coverage to create.
      raster2Model - is the MathTransform that maps from the raster space to the model space.
      roi - Optional ROI used as Mask
      Returns:
      a GridCoverage
      Throws:
      IOException
    • checkName

      protected boolean checkName(String coverageName)
      Overrides:
      checkName in class org.geotools.coverage.grid.io.AbstractGridCoverage2DReader
    • getGridCoverageCount

      public int getGridCoverageCount()

      Number of coverages for this reader is 1

      Specified by:
      getGridCoverageCount in interface org.geotools.api.coverage.grid.GridCoverageReader
      Overrides:
      getGridCoverageCount in class org.geotools.coverage.grid.io.AbstractGridCoverage2DReader
      Returns:
      the number of coverages for this reader.
    • getGroundControlPoints

      public org.geotools.coverage.grid.io.GroundControlPoints getGroundControlPoints()
      Overrides:
      getGroundControlPoints in class org.geotools.coverage.grid.io.AbstractGridCoverage2DReader
    • getFiles

      protected List<org.geotools.api.data.FileGroupProvider.FileGroup> getFiles()
      Overrides:
      getFiles in class org.geotools.coverage.grid.io.AbstractGridCoverage2DReader
    • getMaskOverviewProvider

      public org.geotools.coverage.grid.io.imageio.MaskOverviewProvider getMaskOverviewProvider()
      Returns the MaskOverviewProvider used by this reader. For testing purposes.