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.

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

3 Answers 3


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

  • 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, 2012 at 17:52
  • You can load in shapes and raster files in R through the packages raster and rgdal. The respective functions are 'readOGR' and 'raster'.
    – Curlew
    Nov 14, 2012 at 12:42
  • @JEquihua You could also rasterize the vector data so that they can be compared in the error matrix.
    – Aaron
    Nov 14, 2012 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.


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


  • 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, 2012 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, 2012 at 18:23

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.