Package org.geotools.gce.geotiff
Class GeoTiffWriteParams
- Object
-
- IIOParam
-
- ImageWriteParam
-
- GeoToolsWriteParams
-
- GeoTiffWriteParams
-
public class GeoTiffWriteParams extends GeoToolsWriteParams
Subclass ofGeoToolsWriteParams
the allows the user to specify parameters to control the process of writing out a GeoTiff file through standardsImageWriteParam
(with possible extensions).This class allows the user to control the output tile size for the GeoTiff file we are going to create as well as the possible compression.
An example of usage of this parameters is as follows:
//getting a format final GeoTiffFormat format = new GeoTiffFormat(); //getting the write parameters final GeoTiffWriteParams wp = new GeoTiffWriteParams(); //setting compression to LZW wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT); wp.setCompressionType("LZW"); wp.setCompressionQuality(0.75F); //setting the tile size to 256X256 wp.setTilingMode(GeoToolsWriteParams.MODE_EXPLICIT); wp.setTiling(256, 256); //setting the write parameters for this geotiff final ParameterValueGroup params = format.getWriteParameters(); params.parameter( AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()) .setValue(wp); //get a reader to the input File GridCoverageReader reader = new GeoTiffReader(inFile, null); GridCoverageWriter writer = null; GridCoverage2D gc = null; if (reader != null) { // reading the coverage gc = (GridCoverage2D) reader.read(null); if (gc != null) { final File writeFile = new File(new StringBuffer(writedir .getAbsolutePath()).append(File.separatorChar) .append(gc.getName().toString()).append(".tiff") .toString()); writer = format.getWriter(writeFile); writer.write(gc, (GeneralParameterValue[]) params.values() .toArray(new GeneralParameterValue[1])); }
- Since:
- 2.3.x
- Author:
- Simone Giannecchini
-
-
Field Summary
-
Fields inherited from class GeoToolsWriteParams
adaptee
-
Fields inherited from class ImageWriteParam
canOffsetTiles, canWriteCompressed, canWriteProgressive, canWriteTiles, compressionMode, compressionQuality, compressionType, compressionTypes, locale, MODE_COPY_FROM_METADATA, MODE_DEFAULT, MODE_DISABLED, MODE_EXPLICIT, preferredTileSizes, progressiveMode, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, tilingMode, tilingSet
-
Fields inherited from class IIOParam
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffset
-
-
Constructor Summary
Constructors Constructor Description GeoTiffWriteParams()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TIFFColorConverter
getColorConverter()
Returns the currentTIFFColorConverter
object that will be used to perform color conversion when writing the image, ornull
if none is set.int
getPhotometricInterpretation()
Returns the current value that will be written to thePhotometricinterpretation
tag.TIFFCompressor
getTIFFCompressor()
Returns theTIFFCompressor
that is currently set to be used by theImageWriter
to encode each image strip or tile, ornull
if none has been set.boolean
isCompressionLossless()
boolean
isForceToBigTIFF()
void
setColorConverter(TIFFColorConverter colorConverter, int photometricInterpretation)
Sets theTIFFColorConverter
object describing the color space to which the input data should be converted for storage in the input stream.void
setForceToBigTIFF(boolean forceToBigTIFF)
void
setTIFFCompressor(TIFFCompressor compressor)
Sets theTIFFCompressor
object to be used by theImageWriter
to encode each image strip or tile.void
unsetColorConverter()
Removes any currently setColorConverter
object andPhotometricInterpretation
tag value.-
Methods inherited from class GeoToolsWriteParams
activateController, canOffsetTiles, canWriteCompressed, canWriteProgressive, canWriteTiles, getAdaptee, getBitRate, getCompressionMode, getCompressionQuality, getCompressionQualityDescriptions, getCompressionQualityValues, getCompressionType, getCompressionTypes, getController, getDefaultController, getDestinationOffset, getDestinationType, getLocale, getLocalizedCompressionTypeName, getPreferredTileSizes, getProgressiveMode, getSourceBands, getSourceRegion, getSourceXSubsampling, getSourceYSubsampling, getSubsamplingXOffset, getSubsamplingYOffset, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getTilingMode, hasController, setCompressionMode, setCompressionQuality, setCompressionType, setController, setDestinationOffset, setDestinationType, setProgressiveMode, setSourceBands, setSourceRegion, setSourceSubsampling, setTiling, setTilingMode, unsetCompression, unsetTiling
-
Methods inherited from class ImageWriteParam
setTiling
-
-
-
-
Method Detail
-
setForceToBigTIFF
public void setForceToBigTIFF(boolean forceToBigTIFF)
-
isForceToBigTIFF
public boolean isForceToBigTIFF()
-
getColorConverter
public TIFFColorConverter getColorConverter()
Returns the currentTIFFColorConverter
object that will be used to perform color conversion when writing the image, ornull
if none is set.- Returns:
- a
TIFFColorConverter
object, ornull
. - See Also:
setColorConverter(TIFFColorConverter, int)
-
getPhotometricInterpretation
public int getPhotometricInterpretation()
Returns the current value that will be written to thePhotometricinterpretation
tag. This method should only be called if a value has been set using thesetColorConverter
method.- Returns:
- an
int
to be used as the value of thePhotometricInterpretation
tag. - Throws:
IllegalStateException
- if no value is set.- See Also:
setColorConverter(TIFFColorConverter, int)
-
getTIFFCompressor
public TIFFCompressor getTIFFCompressor()
Returns theTIFFCompressor
that is currently set to be used by theImageWriter
to encode each image strip or tile, ornull
if none has been set.- Returns:
- compressor the
TIFFCompressor
to be used for encoding, ornull
if none has been set (allowing the writer to choose its own). - Throws:
IllegalStateException
- if the compression mode is notMODE_EXPLICIT
.- See Also:
setTIFFCompressor(TIFFCompressor)
-
isCompressionLossless
public boolean isCompressionLossless()
- Overrides:
isCompressionLossless
in classGeoToolsWriteParams
-
setColorConverter
public void setColorConverter(TIFFColorConverter colorConverter, int photometricInterpretation)
Sets theTIFFColorConverter
object describing the color space to which the input data should be converted for storage in the input stream. In addition, the value to be written to thePhotometricInterpretation
tag is supplied.- Parameters:
colorConverter
- aTIFFColorConverter
object, ornull
.photometricInterpretation
- the value to be written to thePhotometricInterpretation
tag in the root IFD.- See Also:
getColorConverter()
,getPhotometricInterpretation()
-
setTIFFCompressor
public void setTIFFCompressor(TIFFCompressor compressor)
Sets theTIFFCompressor
object to be used by theImageWriter
to encode each image strip or tile. A value ofnull
allows the writer to choose its own TIFFCompressor.Note that invoking this method is not sufficient to set the compression type:
must be invoked explicitly for this purpose. The following code illustrates the correct procedure:setCompressionType()
TIFFImageWriteParam writeParam; TIFFCompressor compressor; writeParam.setCompressionMode(writeParam.MODE_EXPLICIT); writeParam.setTIFFCompressor(compressor); writeParam.setCompressionType(compressor.getCompressionType());
IfcompressionType
is set to a value different from that supported by theTIFFCompressor
then the compressor object will not be used.If the compression type supported by the supplied
TIFFCompressor
is not among those in
, then it will be appended to this array after removing any previously appended compression type. IfcompressionTypes
compressor
isnull
this will also cause any previously appended type to be removed from the array.- Parameters:
compressor
- theTIFFCompressor
to be used for encoding, ornull
to allow the writer to choose its own.- Throws:
IllegalStateException
- if the compression mode is notMODE_EXPLICIT
.- See Also:
getTIFFCompressor()
-
unsetColorConverter
public void unsetColorConverter()
Removes any currently setColorConverter
object andPhotometricInterpretation
tag value.
-
-