Package noaa.coastwatch.io
Class GeoTIFFWriter
java.lang.Object
noaa.coastwatch.io.GeoTIFFWriter
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 Summary
Modifier and TypeFieldDescriptionstatic final int
The TIFF deflate compression type.static final int
The TIFF JPEG compression type.static final int
The TIFF LZW compression type.static final int
The TIFF none compression type.static final int
The TIFF PackBits compression type.static final int
The TIFF buffer type for 8-bit unsigned integer data.static final int
The TIFF buffer type for 32-bit floating point data.static final int
The TIFF buffer type for 16-bit unsigned integer data. -
Constructor Summary
ConstructorDescriptionGeoTIFFWriter
(ImageOutputStream output, EarthImageTransform trans) Creates a new GeoTIFF writer using the specified output stream, earth image transform, and no TIFF compression.GeoTIFFWriter
(ImageOutputStream output, EarthImageTransform trans, int compress) Creates a new GeoTIFF writer using the specified output stream, earth image transform, and compression. -
Method Summary
Modifier and TypeMethodDescriptionstatic RenderedImage
createImageForData
(int width, int height, List<float[]> floatDataList, int bufferType) Creates a multibanded image based on data from 32-bit float arrays.void
encode
(RenderedImage image) Writes a GeoTIFF file to the output stream using the specified image data.void
encodeImages
(List<RenderedImage> imageList) Writes a multi-image GeoTIFF file to the output stream using the specified image data.void
Sets the Artist TIFF field.void
setComputer
(String computer) Sets the HostComputer TIFF field.void
setDescription
(String description) Sets the ImageDescription TIFF field.void
setSoftware
(String software) Sets the Software TIFF field.
-
Field Details
-
COMP_NONE
public static final int COMP_NONEThe TIFF none compression type.- See Also:
-
COMP_DEFLATE
public static final int COMP_DEFLATEThe TIFF deflate compression type.- See Also:
-
COMP_PACK
public static final int COMP_PACKThe TIFF PackBits compression type.- See Also:
-
COMP_LZW
public static final int COMP_LZWThe TIFF LZW compression type.- See Also:
-
COMP_JPEG
public static final int COMP_JPEGThe TIFF JPEG compression type.- See Also:
-
TYPE_BYTE
public static final int TYPE_BYTEThe TIFF buffer type for 8-bit unsigned integer data.- See Also:
-
TYPE_USHORT
public static final int TYPE_USHORTThe TIFF buffer type for 16-bit unsigned integer data.- See Also:
-
TYPE_FLOAT
public static final int TYPE_FLOATThe TIFF buffer type for 32-bit floating point data.- See Also:
-
-
Constructor Details
-
GeoTIFFWriter
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
Sets the ImageDescription TIFF field.- Parameters:
description
- the description of the image.
-
setArtist
Sets the Artist TIFF field.- Parameters:
artist
- the person who created the image.
-
setSoftware
Sets the Software TIFF field.- Parameters:
software
- the name and version number of the software package(s) used to create the image.
-
setComputer
Sets the HostComputer TIFF field.- Parameters:
computer
- the computer and/or operating system in use at the time of image creation.
-
encode
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
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
-