[Gdal-dev] Creating an empty ColorTable in C++
Frank Warmerdam
warmerdam at pobox.com
Tue Aug 29 15:18:09 EDT 2006
Roger Bivand wrote:
> My plan was to pass from R to GDAL the handles to two data sets, the
> output one of which would get populated by the color index band and the
> color table. I now see a clean error exit:
>
> Error in rgdal:::SGDF2RGB(xx) :
> GDAL Error 6: SetColorTable() not supported for existing TIFF files.
>
> which suggests that I should rather initiate the output dataset in my
> C/C++ code.
Roger,
I think the key here is that the GeoTIFF driver in GDAL only allows you
to assign a pseudocolor table to a file before you start any raster data.
>> I suspect that the GetColorTable() is returning NULL which is causing the
>> crash later on.
>>
>> Also, I notice you were using the C++ method to fetch the color table.
>> It is up to you, but if you were to use only the C API in an R interface
>> to GDAL it would make things much less "version fragile". That is, new
>> versions of GDAL could be substituted without necessarily having to
>> recompile the R wrappers as the C API is much more ABI stable than the
>> C++ API.
>>
>
> I'm very much building on and maintaining Tim Keitt's elegant C++ code,
> which is written C++ style; as is evident C++ is not a language I enjoy,
> but I would not want to have to rewrite Tim's earlier work. So the code
> has stayed a mixture of elegance where I haven't done anything and
> muddling through where I have written things.
OK, I can understand the desire to not rewrite everything. I just wanted
to raise the issue.
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