[gdal-dev] Can't get colour table for GeoTIFF

Frank Warmerdam warmerdam at pobox.com
Mon Jul 15 16:10:25 PDT 2013


Nike,

The gdalinfo report on the file is as follows.  It is an RGBA file - that
is it has four bands which are red, green, blue and alpha.  It appears you
are configured to only work with single band pseudo-colored images (images
with a palette).  I suppose you will need to generalize your code for this
case.

gdalinfo jrc_21.tiff
Driver: GTiff/GeoTIFF
Files: jrc_21.tiff
Size is 1009, 753
Coordinate System is:
PROJCS["WGS 84 / UTM zone 32N",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",9],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","32632"]]
Origin = (470363.734899999981280,5073657.708399999886751)
Pixel Size = (2.060455896927651,-2.061088977423639)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_XRESOLUTION=96
  TIFFTAG_YRESOLUTION=96
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (  470363.735, 5073657.708) (  8d37' 6.69"E, 45d48'57.04"N)
Lower Left  (  470363.735, 5072105.708) (  8d37' 7.04"E, 45d48' 6.76"N)
Upper Right (  472442.735, 5073657.708) (  8d38'43.03"E, 45d48'57.35"N)
Lower Right (  472442.735, 5072105.708) (  8d38'43.35"E, 45d48' 7.07"N)
Center      (  471403.235, 5072881.708) (  8d37'55.03"E, 45d48'32.06"N)
Band 1 Block=1009x2 Type=Byte, ColorInterp=Red
  NoData Value=0
Band 2 Block=1009x2 Type=Byte, ColorInterp=Green
  NoData Value=0
Band 3 Block=1009x2 Type=Byte, ColorInterp=Blue
  NoData Value=0
Band 4 Block=1009x2 Type=Byte, ColorInterp=Alpha
  NoData Value=0



On Mon, Jul 15, 2013 at 4:07 PM, Nik Sands <nixanz at nixanz.com> wrote:

> Hi!
>
> I'm using the code below as part of a routine to warp images.  For most
> images it works fine.  However, for one of my users, their images are being
> converted from full colour to black and white which is not supposed to
> happen.  I've narrowed down the issue to the code below where 'hCT' remains
> NULL.  An example of one such source image can be downloaded at:
>
>         https://dl.dropboxusercontent.com/u/12436846/jrc_21.tiff
>
> I guess I must be doing something wrong in my code, but can't figure it
> out.  Could somebody please help me to understand how to do this correctly?
>
> Ie, how to I get the colour table from the image linked to above, and set
> that colour table for my destination image?
>
> Cheers,
> Nik.
>
>
>
> GDALColorTableH hCT = GDALGetRasterColorTable( GDALGetRasterBand(hSrcDS,1)
> );
>
> if ( hCT == NULL )
>         NSLog(@"Failed to get colour table.");
> else
>         GDALSetRasterColorTable( GDALGetRasterBand(hDstDS,1), hCT );
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
---------------------------------------+--------------------------------------
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    | Geospatial Software Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130715/c6128b83/attachment.html>


More information about the gdal-dev mailing list