org.geotools.gce.geotiff
Class GeoTiffWriteParams

Object
  extended by IIOParam
      extended by ImageWriteParam
          extended by GeoToolsWriteParams
              extended by GeoTiffWriteParams

public final 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
                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
Module:
modules/plugin/geotiff (gt-geotiff.jar)

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
GeoTiffWriteParams()
          Default constructor.
 
Method Summary
 
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, isCompressionLossless, setCompressionMode, setCompressionQuality, setCompressionType, setController, setDestinationOffset, setDestinationType, setProgressiveMode, setSourceBands, setSourceRegion, setSourceSubsampling, setTiling, setTilingMode, unsetCompression, unsetTiling
 
Methods inherited from class ImageWriteParam
setTiling
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeoTiffWriteParams

public GeoTiffWriteParams()
Default constructor.



Copyright © 1996-2010 Geotools. All Rights Reserved.