TrainImageClassifier .satellite

Hey! So I want to classificate trees, roads, houses etc on a sat image by using TrainImageClassifier. Unfortunately The following error keeps happening.

Does somebody knows a solution?

QGIS version: 3.22.6-Białowieża

QGIS code revision: b6f33b1a

Qt version: 5.15.2

Python version: 3.9.5

GDAL version: 3.4.2

GEOS version: 3.10.2-CAPI-1.16.0

PROJ version: Rel. 9.0.0, March 1st, 2022

PDAL version: 2.3.0 (git-version: 1c17a7)

Algorithm started at: 2022-05-07T12:04:07

Algorithm ‘TrainImagesClassifier’ starting…

Input parameters:

{ ‘io.il’ : [‘C:/Users/31681/Documents/8.JJODATASCIENCE/1.BOMENBEHOUDVUGHT/2.Satellite Tree Guard/qgis/exp2_kaderingresult.tif’], ‘io.vd’ : [‘derle.shp’], ‘io.valid’ : None, ‘io.imstat’ : ‘C:\Users\31681\Documents\8.JJODATASCIENCE\1.BOMENBEHOUDVUGHT\2.Satellite Tree Guard\qgis\exp3_stats.xml’, ‘io.out’ : ‘C:/Users/31681/Documents/8.JJODATASCIENCE/1.BOMENBEHOUDVUGHT/2.Satellite Tree Guard/qgis/exp3_knnmodel.xml’, ‘io.confmatout’ : ‘C:/Users/31681/Documents/8.JJODATASCIENCE/1.BOMENBEHOUDVUGHT/2.Satellite Tree Guard/qgis/exp3_confmatrix.xml’, ‘cleanup’ : True, ‘sample.mt’ : 1000, ‘sample.mv’ : 1000, ‘sample.bm’ : 1, ‘sample.vtr’ : 0.8, ‘sample.vfn’ : ‘id’, ‘elev.dem’ : ‘’, ‘elev.geoid’ : ‘’, ‘elev.default’ : 0, ‘classifier’ : ‘knn’, ‘classifier.knn.k’ : 32, ‘rand’ : 0 }

2022-05-07 12:04:07 (INFO) TrainImagesClassifier: Default RAM limit for OTB is 256 MB

2022-05-07 12:04:07 (INFO) TrainImagesClassifier: GDAL maximum cache size is 789 MB

2022-05-07 12:04:07 (INFO) TrainImagesClassifier: OTB will use at most 16 threads

2022-05-07 12:04:08 (INFO): Loading metadata from official product

2022-05-07 12:04:08 (INFO) TrainImagesClassifier: Polygon analysis…

2022-05-07 12:04:08 (INFO) TrainImagesClassifier: Elevation management: setting default height above ellipsoid to 0 meters

2022-05-07 12:04:08 (INFO): Estimated memory for full processing: 45.2883MB (avail.: 256 MB), optimal image partitioning: 1 blocks

2022-05-07 12:04:08 (INFO): Estimation will be performed in 1 blocks of 1847x1074 pixels

Analyze polygons…: 100% [**************************************************] (0s)

2022-05-07 12:04:08 (INFO) TrainImagesClassifier: Sampling rates…

2022-05-07 12:04:08 (INFO) TrainImagesClassifier: Sampling strategy : fit the number of samples based on the smallest class

2022-05-07 12:04:08 (INFO) TrainImagesClassifier: Sampling rates for image 1 : className requiredSamples totalSamples rate

0 760 1495 0.508361

1 760 1699 0.447322

2 760 760 1

3 760 1248 0.608974

4 760 1153 0.65915

2022-05-07 12:04:08 (INFO) TrainImagesClassifier: Sample selection…

2022-05-07 12:04:08 (INFO) TrainImagesClassifier: Elevation management: setting default height above ellipsoid to 0 meters

2022-05-07 12:04:08 (INFO) TrainImagesClassifier: Sampling strategy : set number of samples for each class

2022-05-07 12:04:08 (INFO) TrainImagesClassifier: Sampling rates : className requiredSamples totalSamples rate

0 760 1495 0.508361

1 760 1699 0.447322

2 760 760 1

3 760 1248 0.608974

4 760 1153 0.65915

2022-05-07 12:04:08 (INFO): Estimated memory for full processing: 45.2883MB (avail.: 256 MB), optimal image partitioning: 1 blocks

2022-05-07 12:04:08 (INFO): Estimation will be performed in 2 blocks of 1408x1074 pixels

Selecting positions with periodic sampler…: 100% [**************************************************] (0s)

2022-05-07 12:04:08 (INFO) TrainImagesClassifier: Sample extraction…

2022-05-07 12:04:08 (INFO): Estimated memory for full processing: 67.9897MB (avail.: 256 MB), optimal image partitioning: 1 blocks

2022-05-07 12:04:08 (INFO): Estimation will be performed in 1 blocks of 1847x1074 pixels

Extracting sample values…: 100% [**************************************************] (0s)

2022-05-07 12:04:08 (INFO): Estimated memory for full processing: 45.2883MB (avail.: 256 MB), optimal image partitioning: 1 blocks

2022-05-07 12:04:08 (INFO): Estimation will be performed in 2 blocks of 1408x1074 pixels

Split samples between training and validation…: 100% [**************************************************] (0s)

2022-05-07 12:04:09 (INFO) TrainImagesClassifier: Model training…

2022-05-07 12:04:09 (FATAL) TrainImagesClassifier: itk::ERROR: StatisticsXMLFileReader(000001E976A155B0): .Satellite is a wrong Extension FileName : Expected .xml

Execution completed in 1.68 seconds

Results:

{‘io.confmatout’: 'C:/Users/31681/Documents/8.JJODATASCIENCE/1.BOMENBEHOUDVUGHT/2.Satellite ’
‘Tree Guard/qgis/exp3_confmatrix.xml’,
‘io.out’: 'C:/Users/31681/Documents/8.JJODATASCIENCE/1.BOMENBEHOUDVUGHT/2.Satellite ’
‘Tree Guard/qgis/exp3_knnmodel.xml’}

Loading resulting layers

Algorithm ‘TrainImagesClassifier’ finished

Dear @jorritxl,

  1. the extension for the output model (io.out) should be .txt.
  2. the extension for the output confusion matrix (io.confmatout) sould be .csv.
  3. How did you produce your statistics file (C:\Users\31681\Documents\8.JJODATASCIENCE\1.BOMENBEHOUDVUGHT\2.Satellite Tree Guard\qgis\exp3_stats.xml) ? It should be the output of the ComputeImagesStatistics application. Can you share with us its content?

Best regards.
Julien :slight_smile:

I see that there is a space in the path of the statistics file, you should rename your directory “2.Satellite Tree Guard” to “2.Satellite_Tree_Guard”.