Python 3 script that generates training and validation samples (geodataframes) from a shapefile database
Image classification is one of the most well known and used operations in remote sensing and GIS. To evaluate the result produced by a supervised classification algorithme; the operator needs to analyse the confusion matrix, Kappa coefficient and overall accuracy generated by using training and validation samples.
These samples are often split in two:
- 2/3 โ Training samples (used to train the model);
- 1/3 โ Validation samples (used to validate the model).
The samples need to be split in a random way as to not influence the classification's evaluation. This why this script has been developed.
The ROI-Auto python3 script reads all of the ESRI shapefiles in a directory, and using a pseudo random number generator; it determines the polygones that are going to be used for the training and validation. Then, it puts them in separate foloders (in the same directory) after backing up the original files. At the end of the operation, a report is generated with the IDs of the polygons chosen for training / validation.
No installation, just run the roi.py (using a python 3 interpreter) inside the MultiPolygons directory.
As of now, the script only supports ESRI shapefiles.
In theory, MultiPoints shapefiles should work, although no test were done to confirm this.
Each MultiPolygon (.shp) must represent one class and one class ONLY. The number of MultiPolygons in the directory must match the number of classes.
The script will not work without the following dependencies: