[Gdal-dev] adding compress to pct2rgb, rgb2pct
Frank Warmerdam
warmerdam at pobox.com
Fri Jan 12 23:46:32 EST 2007
Matt Wilkie wrote:
> hello all,
>
> Wannabee coder here would like some help learning how to extend the
> pct2rgb, rgb2pct python scripts to include -co options, compression
> specifically. Can anyone point me to some docs or examples which might
> help me on my way?
Matt,
You will want to include the creation option in the CreateCopy() call.
Something like this:
tif_ds = gdal.Open( tif_filename )
dst_driver.CreateCopy( dst_filename, tif_ds, options = [ "COMPRESS=LZW" ] )
tif_ds = None
You will also need to force force the CreateCopy() step to happen even if
the output format is GTiff. This could be accomplished by changing this:
if format == 'GTiff':
tif_filename = dst_filename
else:
tif_filename = 'temp.tif'
To this:
tif_filename = 'temp.tif'
If you wanted to be able to pass creation options on the commandline a bit
of extra work would also be required.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGeo, http://osgeo.org
More information about the Gdal-dev
mailing list