[gdal-dev] reading attribute values out of erdas img

John Morgan jdmorgan at unca.edu
Wed Jan 18 10:38:38 EST 2012


Hello,
I am fairly new to GDAL but impressed w/ its functionality.  I have an
ERDAS img file that has categorical data in it (data type).  I am
attempting to read out the  categorical data for the purposes of eventually
classifying it in a map server file.  I have found one example of this but
am not sure if this is the best way to go about it.  Any feedback would be
appreciated.  Here is what I have so far:

#! /usr/bin/python
from osgeo import gdal, gdalconst
from gdalconst import *

ds =
gdal.Open('/flood/fsdata-internal/efetac_nasa/AncillaryData/foresttype.img',
gdal.GA_ReadOnly)
# get image size
rows = ds.RasterYSize
cols = ds.RasterXSize
bands = ds.RasterCount

# create a list to store band data in
bandList = []
# read in bands and store all the data in bandList
for i in range(bands):
    band = ds.GetRasterBand(i+1)
    data = band.ReadAsArray(0, 0, cols, rows)
    bandList.append(data)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120118/8defddca/attachment.html


More information about the gdal-dev mailing list