Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have around 150 images (rasters), each one is just a map of certain "classes", e.g. pixel value 1=forest.

I also have a shapefile that consists of roughly the same area as the 150 images constitute when put together. The shapefile also includes the clasee 1=forest. How could I go around to compare if the "classes" match, and how well do they. Any ideas? I'm using python and Qgis.

Any idea would be appreciated. Greetings.


share|improve this question
do you have access to SEXTANTE tools? or better yet GRASS? – nickves Sep 21 '12 at 16:23
No, but I could. Grass is opensource right. If I get it what should I do? – JEquihua Sep 21 '12 at 16:40

Your case sounds like a statistical problem and a good match for an error matrix. I would recommend reading "A Review of Assessing the Accuracy of Classifications of Remotely Sensed Data" (Congalton, 1991). Congalton's book "Assessing the Accuracy of Remotely Sensed Data: Principles and Practices" is a great reference for all matters relating to sampling and accuracy assessments of land classification data.

I would also recommend looking at equivalence tests, which can be accomplished very easily using the opensource statistical software R and the equivalence package. The equivalence.xyplot() function is a great way to visualize whether or not two datasets are statistically equivalent:

equivalence.xyplot Constructs graphical regression-based tests of equivalence inside a lattice coplot

enter image description here

share|improve this answer
How would I load the images and the shapefile in R. Im quite familiar with R but havent used it for this. Images using gdal I guess (they are geotiffs). The shapefile? Or can the data from the images and shapefile be saved to a csv or text or something? that would be great. I don't know is this is a terrible approach. Just started working on this and am absolutely clueless about gis stuff. – JEquihua Sep 21 '12 at 17:52
you can loadin shapes and raster files in R through the packages "raster" and "rgdal". The repesctive functions are 'readOGR' and 'raster' – Curlew Nov 14 '12 at 12:42
@JEquihua You could also rasterize and the vector data so that they can be compared in the error matrix. – Aaron Nov 14 '12 at 15:35

If you plan to use GRASS, you could use v.rast.stats to assign the raster statistics (univariate or categorical) to each polygon. In your case, you might want to assign the median value or calculate the majority class value for the pixel values within the polygon.

You could then compute an error matrix using r.kappa or do the analysis in R or another stats package to see how well they "match". You can assess the class accuracies in terms of the commission and omission errors.

A for loop will automate this procedure for the 150 rasters.

share|improve this answer
This sounds great, I'll try this out. – JEquihua Sep 21 '12 at 17:50
If you need/want to use R, you should consider using the following R packages: rgdal and spgrass6. The former library will allow you to read shp/tiffs into R, while the second allows for read/write of GRASS data from R. Hope that helps. [] [] – dmci Sep 22 '12 at 15:55

For spot-checking you could load a shapefile over a raster and then use the raster Value Tool, which will display raster pixel values as you move the pointer around the screen. You can display and compare raster values for several raster layers, if required (with graphs).


share|improve this answer
I didn't find the raster value tool. Under raster I just see "raster calculator". Another thing, this sounds a little bit manual. Is there a more automated way to create comparison statistics? maybe using the shapfile and the rasters as databases and comparing them at this level? – JEquihua Sep 21 '12 at 17:48
It's a plug-in; in the plug-in installer search on "Value Tool". Then enable it, View -> Panels -> Value Tool. N. – nhopton Sep 21 '12 at 18:23

Your Answer


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.