7

How do I calculate area of several vegetation types in a raster (.img file type) image. They are color coded. Am using QGIS (1.8.0) and ERDAS 9.2.

3 Answers 3

2

you can check out Qgis Sextante Toolbox in plugins repository. it has lots of geoprocessing alagorithm in it.

SEXTANTE is a spatial data analysis library and a powerful geoprocessing framework.The main aim of SEXTANTE is to provide a platform for the easy implementation, deployment and usage of rich geoprocessing functionality. It currently contains more than three hundred algorithms for both raster and vector data processing, as well as tabular data analysis tools.

and there is a good answer for classified vectorizing here from @nhopton. follow his direction to achieve what you want.

2

You can open the raster image as a GDALDataset :
poDataset = (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly );

Then get the raster band containing the color codes with :
GDALRasterBand *poBand;
poBand = poDataset->GetRasterBand( i );
where "i" represents the raster band id.

Then iterate over the raster band pixels and read each pixel color code value to count the number of pixels for a selected color code.
Knowing the area represented by a single pixel you should be able to calculate the area for all the pixels representing the selected color code.

To read values from a raster band you should use :
CPLErr GDALRasterBand::RasterIO ( GDALRWFlag eRWFlag,
int nXOff,
int nYOff,
int nXSize,
int nYSize,
void * pData,
int nBufXSize,
int nBufYSize,
GDALDataType eBufType,
int nPixelSpace,
int nLineSpace
)

For a full documentation about the GDAL LIBRARY : http://gdal.org/index.html
GDAL class list : http://gdal.org/annotated.html
Get some help with the GDAL API : http://gdal.org/gdal_tutorial.html

0

You can do this task with Erdas itself.

Convert the color coded image to vector by using raster to vector option under vector utilities tool. Convert the resulted Arcinfo vector file to shapefile using Import/Export option.

Open the vector file in QGIS. You can see the vector polygons corresponding to the vegetation class are coded as 1, 2, 3 in grid code field of attribute table. Calculate the area by using field calculator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.