Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

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.

Again, I hope I made sense. Any help is greatly appreciated. Thanks.

share|improve this question
    
Have you tried to convert vector to raster? gis.stackexchange.com/questions/22704/… –  nadya Oct 15 '12 at 20:04
add comment

3 Answers

If the raster cell value does indeed contain land use data then you are able to sample the value to a Vector layer with GRASS.

I haven't used this method but it should work something like:

First modify your vector table structure to suit your purpose in QGIS Use the GRASS plugin, create mapset for your area Load the data into Grass (v.in.ogr.qgis, r.in.gdal.qgis) Sample the raster cells using v.sample into you vector table columns Export vector to shapefile (v.out.ogr)

share|improve this answer
add comment

I think you are looking for a way that similar to Arcmap's Zonal Statistics function.

Not sure if you were familiar with Postgis or not. But Postgis dose support the Zonal Statistics function. Based on the documentation I found from Postgis' website:

"ST_SummaryStats — Returns summary stats consisting of count,sum,mean,stddev,min,max for a given raster band of a raster or raster coverage. Band 1 is assumed is no band is specified."

There is an example on that page about "Summarize pixels that intersect buildings of interest" maybe helpful to you.

In terms to your budget, I would say Postgis and PostgreSQL database is completely free, so all you need is to invest some time on it.

Hope it is a useful option for solving your problem.

share|improve this answer
add comment

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).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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