Accuracy Assesment in SNAP with Python

Hello everyone,
I have some problem. I want to make accuracy assessment in SNAP but I don’t find to easy step. Can I add Python Extensions in SNAP?
Thanks :slight_smile:

A manual example for one class is given in this tutorial: Landcover classification with Sentinel-1 GRD

Thank you @ABraun but I want to automatically step with Python Code. Are there code packets?

Depends a bit on how your validation data looks like. Do you have field reference?

I have 6 classes in classification images. What did you mean by ‘field reference’?

To perform an accuracy assessment, you need independent validation data you can use as reference. The classifcation cannot validate itself automatically.

I have ‘the pins’ for accuracy assessment to homogeneously for each class.
I created in SNAP. Can I handle with this pins to accuracy assessment automatically in Python Code? What are the Python Codes?

You can then use the mask manager to extract the class of the pixel among all pins and export it to a file. The rest can easily be done with MS Excel, for example by counting the true positives / false negatives / true negatives / false positives (with a pivot table).

If you insist on a python solution you would probably find some existing methods, but these surely need some adjustment to match the output of the Pin Manager (data structure, column names…).
Are you familiar with using python?

I understand you say, thank you for information :slight_smile: I know some Python Program.

That’s good. This one, for example, directly takes a raster (you can use the img file in the .data folder) and a vector set of points to automatically do it: GitHub - JaimeLoya/AccurAssess: Carry out the accuracy assessment of a thematic categorical map taking into account the sampling design.
There are a copuple of sample files which you can use to get behind the required structure.

This one is even simpler, at the end you see that it only takes two lists (actual and predicted) which are systematically compared against each other: Python Class for Performance Assessment of Classification Tasks · GitHub

thank you for your help. I hope, I will create

Good luck! Feel free to report which of them was helpful to you in the end. This could be interesting to other SNAP users as well.

1 Like