[GIS] How to sum raster image values with vector overlay

qgisrastervector

I'm new to this and haven't been able to figure out how to do this on my own.

I have two files: a raster image of land use data and a vector-based shapefile of my territories.

The raster image has values like so: 11 = water, 21 = developed – open, 22 = developed – low, 23 = developed – medium, 41 = forest, 71 = grassland, 82 = cultivated crop, etc. Overall, I've got about 30 distinct values. The resolution of this image is pretty big (1m squares, I think) and the filesize is about 16 gigs.

I was to add a set of columns to my shapefile, one new column for each of the possible land use values. The column names would be like so: value_11, value_21, vaule_22, value_23, etc. Then I'd like to sum up the number of pixels in each shape that correspond to each value. So, if there are 1200 pixels that have a value of 11, then column value_11 would have 1200 in it.

I've used qgis to get the vector and raster files to load at the same time and they're georeffed correctly. It displays beautifully.

I'm not sure if I'm making this clear, but I'd like a count for every combination of each vector-based polygon and the unique values from the raster image within that polygon. If I need to do this in multiple passes, that's fine.

Using qgis, I was able to get average/median/mode/min/max of raster values within each polygon, but that's useless to me. I need the count of each distinct land use value. Eventually, I want to load the final shapefile into SQL Server 2008 and be able to write queries against it. I'd like to take a series of points, find out which polygon they are in, and determine how many water, developed, forest, etc. pixels are in that polygon.

Regarding software, I've played with several free/open source programs (such as QGIS, SAGA, etc), but I just don't know enough about what I'm trying to do to get anything to work. I can download whatever I might need, but I don't have a budget, so if ARCGIS or something expensive is the only way to do this, then I'm out of luck. Once I get the shapefile created, I can get it back into SQLServer and I can write the queries there to do what I want. I just need to get build the shapefile with the land use data added to it.

Best Answer

For GRASS GIS Zonal statistics, see http://grasswiki.osgeo.org/wiki/Zonal_statistics

It looks as if you want to use "v.vect.stats": count points in areas, calculate statistics from point attributes (needs GRASS 7).