Train classifier

Hello,

I have a train and test samples in tif format, how can convert this raster data to vector data to using it in a train classifier ?

Thank you.

You have two tif files containing label values for the different classes, one for training and one for testing ?

In this case, I don’t think we have an application in OTB that would convert them to vector data. However, you can use the gdal script gdal_polygonize.py (this script is in the binary package of OTB) that will convert each 4 connected component (areas with the same label) into a polygon. The resulting shapefile can then be used in the TrainImageClassifier.

Cédric

I will try this thank you so much.

I don’t know if this is the right place to mention, but I think that adding the possibility to train with an image instead of a vector would be very useful for many applications. I had to do it for myself in a custom app because converting a large labelled image into vector is not always possible. I can share some code (multi-threaded sampler) if needed, but if I understood well there is already an internal conversion of the polygon to rasters at some stages of the sampling, so I guess that the existing framework would not need too much changes.