Class GeoTIFFWriter

java.lang.Object
noaa.coastwatch.io.GeoTIFFWriter

public class GeoTIFFWriter extends Object

A GeoTIFF writer uses an earth image transform and rendered image to create a TIFF file with extra TIFF tags decribing the earth location of the image data. The GeoTIFF content conforms to the GeoTIFF specification version 1.8.2 as obtained from the RemoteSensing.Org website. The TIFF tag types and Java types are documented in the javax.imageio.plugins.tiff.TIFFField class and extra notes on encoding TIFF metadata linked from the javax.imageio package Javadoc.

As of version 3.5.1, this class was re-written to use the javax.imageio API rather than Java Advanced Imaging (JAI), due to conflicts between JAI and JDK 11.

Since:
3.1.3
Author:
Peter Hollemans
  • Field Details

    • COMP_NONE

      public static final int COMP_NONE
      The TIFF none compression type.
      See Also:
    • COMP_DEFLATE

      public static final int COMP_DEFLATE
      The TIFF deflate compression type.
      See Also:
    • COMP_PACK

      public static final int COMP_PACK
      The TIFF PackBits compression type.
      See Also:
    • COMP_LZW

      public static final int COMP_LZW
      The TIFF LZW compression type.
      See Also:
    • COMP_JPEG

      public static final int COMP_JPEG
      The TIFF JPEG compression type.
      See Also:
    • TYPE_BYTE

      public static final int TYPE_BYTE
      The TIFF buffer type for 8-bit unsigned integer data.
      See Also:
    • TYPE_USHORT

      public static final int TYPE_USHORT
      The TIFF buffer type for 16-bit unsigned integer data.
      See Also:
    • TYPE_FLOAT

      public static final int TYPE_FLOAT
      The TIFF buffer type for 32-bit floating point data.
      See Also:
  • Constructor Details

    • GeoTIFFWriter

      public GeoTIFFWriter(ImageOutputStream output, EarthImageTransform trans) throws IOException
      Creates a new GeoTIFF writer using the specified output stream, earth image transform, and no TIFF compression.
      Parameters:
      output - the output stream for writing.
      trans - the earth image transform for earth location metadata.
      Throws:
      IOException - if an error occurred writing to the output stream.
    • GeoTIFFWriter

      public GeoTIFFWriter(ImageOutputStream output, EarthImageTransform trans, int compress) throws IOException
      Creates a new GeoTIFF writer using the specified output stream, earth image transform, and compression.
      Parameters:
      output - the output stream for writing.
      trans - the earth image transform for earth location metadata.
      compress - the TIFF compression type, either COMP_NONE, COMP_DEFLATE, COMP_PACK, COMP_LZW, or COMP_JPEG.
      Throws:
      IOException - if an error occurred setting up the GeoTIFF output.
  • Method Details

    • setDescription

      public void setDescription(String description)
      Sets the ImageDescription TIFF field.
      Parameters:
      description - the description of the image.
    • setArtist

      public void setArtist(String artist)
      Sets the Artist TIFF field.
      Parameters:
      artist - the person who created the image.
    • setSoftware

      public void setSoftware(String software)
      Sets the Software TIFF field.
      Parameters:
      software - the name and version number of the software package(s) used to create the image.
    • setComputer

      public void setComputer(String computer)
      Sets the HostComputer TIFF field.
      Parameters:
      computer - the computer and/or operating system in use at the time of image creation.
    • encode

      public void encode(RenderedImage image) throws IOException
      Writes a GeoTIFF file to the output stream using the specified image data.
      Parameters:
      image - the image to write.
      Throws:
      IOException - if an error occurred writing to the output stream.
    • createImageForData

      public static RenderedImage createImageForData(int width, int height, List<float[]> floatDataList, int bufferType)
      Creates a multibanded image based on data from 32-bit float arrays.
      Parameters:
      width - the image width in pixels.
      height - the image height in pixels.
      floatDataList - the list of float data arrays for the bands, each of length width*height.
      bufferType - rendered image buffer type. Supported types are DataBuffer.TYPE_FLOAT (32-bit float), DataBuffer.TYPE_BYTE (8-bit unsigned byte), and DataBuffer.TYPE_USHORT (16-bit unsigned short). The buffer type determines what data type is ultimately encoded to the TIFF image. Any Float.NaN values in the data arrays are written as zeroes for integer data types.
      Returns:
      an image suitable for passing directly to the encode(java.awt.image.RenderedImage) method. The image should not be used for display.
      Since:
      3.5.1
    • encodeImages

      public void encodeImages(List<RenderedImage> imageList) throws IOException
      Writes a multi-image GeoTIFF file to the output stream using the specified image data.
      Parameters:
      imageList - the list of images to write.
      Throws:
      IOException - if an error occurred writing to the output stream.
      Since:
      3.5.1