[gdal-dev] How do we know the number of raster bands of a WKT Raster object?

Frank Warmerdam warmerdam at pobox.com
Tue Jul 7 20:30:11 EDT 2009


Jorge Arévalo wrote:
> Hello,
> 
> I have a doubt: I have a raster loaded in PostgreSQL with
> gdal2wktraster, and I'm not sure of the best way to know the number of
> raster bands the raster has. The fields "pixel_types" and
> "nodata_values" from raster_columns table are arrays with one element
> per raster band, so, counting the number of elements of one of these
> arrays, I can get the number of raster bands. But it doesn't seem to
> be a very "elegant" way. Do we have another way to do this?

Jorge,

I believe taking the count of values in the pixel_types array is the
correct approach to determining the number of bands.

Elegant is in the eye of the beholder.

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    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list