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.
You can open the raster image as a GDALDataset :
Then get the raster band containing the color codes with :
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.
To read values from a raster band you should use :
I hope this helps!
you can check out Qgis Sextante Toolbox in plugins repository. it has lots of geoprocessing alagorithm in it.
and there is a good answer for classified vectorizing here from @nhopton. follow his direction to achieve what you want.
i hope it helps you...
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.
Hope this will help you.