[Gdal-dev] Datatype of bands

Matt Hanson mhanson at photon.com
Mon Aug 21 11:16:49 EDT 2006


Frank, Thanks for the answers.  I'm going to assume that all bands are of the same datatype.
 
A related question - is there a way I can get the datatype of a band as a typename, rather then as a GDAL enum or a string.   I want to be able to query a dataset and get the datatype so I can create a template of a specific type.
 
matt

________________________________

From: Frank Warmerdam [mailto:warmerdam at pobox.com]
Sent: Fri 8/18/2006 3:42 PM
To: Matt Hanson
Cc: Gdal-dev at lists.maptools.org
Subject: Re: [Gdal-dev] Datatype of bands



Matt Hanson wrote:
> Hi,  I have a couple questions regarding the data type of bands in a single
> dataset.   Each spectral band in a file could potentially have a different
> datatype.
>
> 1) Is there an easy way to retrieve the smallest data type that can hold
> the values across all bands, or only by iterating through with
> GetRasterband()->GetRasterDataType() and calls to GDALDataTypeUnion()?

Matt,

There is no convience function for this.   Your approach is the right one.

> 2) It looks like GDAL cannot *create* a file with varying data types across
> spectral bands unless it is done with first a Create(), then using
> AddBands() to add each band individually.  But AddBands() isn't supported
> by all data formats.  I haven't been able to find a list of formats that
> support AddBand...did I miss it?

There is no list of formats supporting AddBand(). You would pretty much have
to inspect the implementations.  In practice I think there are very very
few that do support it.  possibly only the MEM and VRT formats.

Format drivers also have the option of honouring the band data type
from the source in the CreateCopy() method.  In practice most just
grab the type of the first band and assume the rest are the same.

Generally speaking it is rare for image files to have different types for
different bands, and while GDAL can expose it when it occurs, many drivers
won't capture it when copying a dataset.

It would be nice if we were more systematic about reporting failures to
honour the original band types when copying.

> 3) Not so much a GDAL question, but I was wondering how common users out
> there have found different datatypes vs. bands to be.  I don't think it's
> all that common unless perhaps elevation maps are bundled in with data, or
> the format contains both raw and calibrated data.  But I don't want to
> immediately make the assumption that all datasets will have identical
> datatypes across all bands. I need to make a decision about if I need to
> support creation of multi-datatype files and was hoping to get feedback on
> if users out there felt this was a safe assumption or a bad one.

Right, it is quite rare.  I think the most common formats to do it are
PCIDSK and Erdas Imagine formats, but even then it is a very small
number of all datasets.

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 OSGF, http://osgeo.org <http://osgeo.org/> 







More information about the Gdal-dev mailing list