[Gdal-dev] Gdalwarp color corruption

Frank Warmerdam warmerdam at pobox.com
Fri Jan 5 11:00:27 EST 2007

Craig Miller wrote:
> I've been using gdalwarp to reproject USGS quads (single band geotif images
> with color table) from UTM zone 10/11 to geographic (EPSG:4326).  If I use
> nearest neighbor sampling (-rn) the color table gets translated correctly,
> but if I use bilinear, cubic, or cubic spline resampling the color table is
> corrupted.  For example, blue water turns brown.  As nearest neighbor
> sampling doesn't always offer up the smoothest results I'm hoping to get
> cubic spline resampling working.  Any suggestions on how to get this working
> w/o corrupting my color table?
> I'm using gdal out of CVS from a couple of weeks ago.
> Gdalwarp -rcs -co "COMPRESS=LZW" -co "TILED=YES" -wo "INIT_DEST=NO_DATA"
> -t_srs EPSG:4326 infile.tif ..\geo\outfile.tif
> I'd be happy to provide sample images, but they are a bit large so I didn't
> want to send them to the list.


The actual resampling algorithms don't (and can't really be expected) to
operate in colormap color space.  Instead they just operate on the raw
pixel values.  If you want to use a "non-ramp" color table with resampling
types other than nearest neighbour you will really need to first convert
your image to 24bit RGB.


pct2rgb.py infile.tif infile_rgb.tif

Then operate on that with other resampling techniques.

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