Class GeoTiffWriteParams

  • public class GeoTiffWriteParams
    extends GeoToolsWriteParams
    Subclass of GeoToolsWriteParams the allows the user to specify parameters to control the process of writing out a GeoTiff file through standards ImageWriteParam (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
                    //setting the tile size to 256X256
                    wp.setTiling(256, 256);
                    //setting the write parameters for this geotiff
                    final ParameterValueGroup params = format.getWriteParameters();
                    //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);
                                    if (gc != null) {
                                            final File writeFile = new File(new StringBuffer(writedir
                                            writer = format.getWriter(writeFile);
                                            writer.write(gc, (GeneralParameterValue[]) params.values()
                                    .toArray(new GeneralParameterValue[1]));
    Simone Giannecchini
    • Constructor Detail

      • GeoTiffWriteParams

        public GeoTiffWriteParams()
        Default constructor.
    • Method Detail

      • setForceToBigTIFF

        public void setForceToBigTIFF​(boolean forceToBigTIFF)
      • isForceToBigTIFF

        public boolean isForceToBigTIFF()
      • getColorConverter

        public TIFFColorConverter getColorConverter()
        Returns the current TIFFColorConverter object that will be used to perform color conversion when writing the image, or null if none is set.
        a TIFFColorConverter object, or null.
        See Also:
        setColorConverter(TIFFColorConverter, int)
      • getPhotometricInterpretation

        public int getPhotometricInterpretation()
        Returns the current value that will be written to the Photometricinterpretation tag. This method should only be called if a value has been set using the setColorConverter method.
        an int to be used as the value of the PhotometricInterpretation tag.
        IllegalStateException - if no value is set.
        See Also:
        setColorConverter(TIFFColorConverter, int)
      • getTIFFCompressor

        public TIFFCompressor getTIFFCompressor()
        Returns the TIFFCompressor that is currently set to be used by the ImageWriter to encode each image strip or tile, or null if none has been set.
        compressor the TIFFCompressor to be used for encoding, or null if none has been set (allowing the writer to choose its own).
        IllegalStateException - if the compression mode is not MODE_EXPLICIT.
        See Also:
      • setColorConverter

        public void setColorConverter​(TIFFColorConverter colorConverter,
                                      int photometricInterpretation)
        Sets the TIFFColorConverter 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 the PhotometricInterpretation tag is supplied.
        colorConverter - a TIFFColorConverter object, or null.
        photometricInterpretation - the value to be written to the PhotometricInterpretation tag in the root IFD.
        See Also:
        getColorConverter(), getPhotometricInterpretation()
      • setTIFFCompressor

        public void setTIFFCompressor​(TIFFCompressor compressor)
        Sets the TIFFCompressor object to be used by the ImageWriter to encode each image strip or tile. A value of null allows the writer to choose its own TIFFCompressor.

        Note that invoking this method is not sufficient to set the compression type: setCompressionType() must be invoked explicitly for this purpose. The following code illustrates the correct procedure:

         TIFFImageWriteParam writeParam;
         TIFFCompressor compressor;
        If compressionType is set to a value different from that supported by the TIFFCompressor then the compressor object will not be used.

        If the compression type supported by the supplied TIFFCompressor is not among those in compressionTypes, then it will be appended to this array after removing any previously appended compression type. If compressor is null this will also cause any previously appended type to be removed from the array.

        compressor - the TIFFCompressor to be used for encoding, or null to allow the writer to choose its own.
        IllegalStateException - if the compression mode is not MODE_EXPLICIT.
        See Also: