Class GeoTiff

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class GeoTiff
    extends java.lang.Object
    implements java.lang.AutoCloseable
    The main class that all geotiff operations are based on. It handles things like loading the geotiff metadata and exposes methods for common transform operations.
    • Constructor Summary

      Constructors 
      Constructor Description
      GeoTiff​(java.io.File file)  
      GeoTiff​(java.io.InputStream inputStream)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      java.util.Optional<? extends org.geolatte.geom.crs.CoordinateReferenceSystem<? extends org.geolatte.geom.Position>> getCoordinateReferenceSystem()  
      <P extends org.geolatte.geom.Position>
      java.util.Optional<org.geolatte.geom.Envelope<P>>
      getEnvelope()
      Calculates the envelope of the geotiff by transforming the lower left and upper right corners of the geotiff into model space.
      GeoTiffMetadata getMetadata()
      Gets the metadata associated with this geotiff.
      ModelType getModelType()
      Returns the ModelType specified inside the geokey metadata of the geotiff, or ModelType.UNKNOWN if the ModelType is unspecified.
      java.awt.image.BufferedImage readImageIntoBuffer()  
      <P extends org.geolatte.geom.Position>
      java.util.Optional<java.awt.Point>
      transformModelPointToRasterPoint​(P modelPoint)
      Transforms a model point into raster space.
      <P extends org.geolatte.geom.Position>
      java.util.Optional<P>
      transformRasterPointToModelPoint​(int rasterX, int rasterY)
      Transforms a point in raster space into model space.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GeoTiff

        public GeoTiff​(java.io.File file)
                throws java.io.IOException
        Throws:
        java.io.IOException
      • GeoTiff

        public GeoTiff​(java.io.InputStream inputStream)
                throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • readImageIntoBuffer

        public java.awt.image.BufferedImage readImageIntoBuffer()
                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • getMetadata

        public GeoTiffMetadata getMetadata()
        Gets the metadata associated with this geotiff.
        Returns:
        The loaded metadata contained in the geotiff.
      • getModelType

        public ModelType getModelType()
        Returns the ModelType specified inside the geokey metadata of the geotiff, or ModelType.UNKNOWN if the ModelType is unspecified.
        Returns:
        The ModelType specified by the geotiff metadata.
        See Also:
        Spec reference
      • transformRasterPointToModelPoint

        public <P extends org.geolatte.geom.Position> java.util.Optional<P> transformRasterPointToModelPoint​(int rasterX,
                                                                                                             int rasterY)
        Transforms a point in raster space into model space. If any parameter needed for the transformation is not specified in the geotiff, the function will return an empty Optional. This function supports specifying raster points outside the raster space of the geotiff, like (-10, -20). Note that the further you stray from any model tiepoints, the more inaccurate the interpolation will probably be.
        Type Parameters:
        P - The type of the point resulting from the transformation, usually a G2D
        Parameters:
        rasterX - The X-coordinate (horizontal axis) of a point in raster space
        rasterY - The Y-coordinate (vertical axis) of a point in raster space
        Returns:
        An Optional containing the transformed point.
      • transformModelPointToRasterPoint

        public <P extends org.geolatte.geom.Position> java.util.Optional<java.awt.Point> transformModelPointToRasterPoint​(P modelPoint)
        Transforms a model point into raster space. If any parameter needed for the transformation is not specified in the geotiff, the function will return an empty Optional. Note that no bounds checking is performed, so it is perfectly fine to receive a result like (-10, -10). Raster coordinates are not rounded, but cut off by simply converting the resulting raster coordinates to integers.
        Type Parameters:
        P - The type of the Position in model, usually a G2D
        Parameters:
        modelPoint - A point in model space.
        Returns:
        An Optional containing the transformed point, or an empty Optional if any information needed for the transformation is not present.
      • getEnvelope

        public <P extends org.geolatte.geom.Position> java.util.Optional<org.geolatte.geom.Envelope<P>> getEnvelope()
        Calculates the envelope of the geotiff by transforming the lower left and upper right corners of the geotiff into model space. If any parameter needed for the transformation is not specified in the geotiff, the function will return an empty Optional.
        Type Parameters:
        P - The type of Positions of the model space, usually a G2D
        Returns:
        An Optional containing the calculated bounding box, or an empty Optional if any information needed for envelope calculation is missing.
      • getCoordinateReferenceSystem

        public java.util.Optional<? extends org.geolatte.geom.crs.CoordinateReferenceSystem<? extends org.geolatte.geom.Position>> getCoordinateReferenceSystem()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.io.IOException