Integrate indices (e.g. NDVI) in OBIA classification

Hi all,

I am a new user of OTB and I am really interested in OBIA classification. Until now I applied the segmentation procedure (using mean shift algorithm), and I would like to move forward with the classification.
I use an multispectral image (Sentinel 2A) with 40 bands. Each 10 bands correspond to 1 season.

So, I would like to ask how can I integrate radiometric indices (e.g.NDVI, SVI) in the TrainVectorClassifier application. Based on the documentation, ComputeImageStatistics is used to create an .xml file with statistics, and it is used in the training procedure.

Is it possible to add external info (NDVI) in these statistics? And how could I combine information of computed indices from different seasons.

Any suggestion would be helpful !!!

Cheers,
Vasilis

Hello,

First of all TrainVectorClassifier takes a vector datasource as input, so you should use the vector output of the segmentation step.

TrainVectorClassifier trains a model based on the features of the geometries of the input vector, the class of the geometry is specifified by the cfield parameter, and the training feature by the featparameter. This means that if you want to use the NDVI you have to add it to the features of the vector.

Do you know the value of the NDVI for each geometry ? How do you define it ? Is it the mean NDVI of all pixels inside the geometry ? If so, you can compute NDVI on the input raster (RadiometricIndices applicationand then use the ZonalStatistics application on the output NDVI to compute the mean for each geometry.

The statistics file is used to provide mean and standard deviation for each feature to normalize the input dataset before the classification, if needed.

Cédric

1 Like

Hi Cedric,

Thanks a lot for your quick reply!

No, I don’t know the value of NDVI for each geometry, but I want to compute it (and also for other indices).
So indeed, it makes sense to integrate the mean value of an index for each geometry using zonal statistics.

But could I use an expression in the training algorithm such as (if mean NDVI <0,35 --> assume it as vegetation?)

Thanks,
Vasilis

I don’t think there is anything in OTB to assign a class to a geometry based on an expression (TrainVectorClassifier trains a machine learning classifer based on a labeled dataset). It is possible to apply an expression to rasters with the BandMath application. Maybe you could use the raster output of ZonalStatistics as input of BandMath instead of the vector output. However this would not be super efficient because the class would be computed for each pixel inside each geometry.

Maybe you could other tools to implement the expression based classification ? Like looping on the geomtries of the vector dataset using OGR (GDAL) python binding.

Cédric

1 Like