Random Forest Classifier struggles with long names

I am training and applying a Random Forest classifier on a stack of multiple Sentinel-1 images which were preprocessed and stacked to one product. Each raster has a separate name including the date.

I train on a raster which is also included in the stack and use the S1 images as features:

The computation starts and seems to work but once the classifier is to be saved, the following message occurs:
“Classifier cannot be saved: some feature bands have same name - Sigma0_VH_db”

grafik

There is not band with this name in the stack, all names are unique and longer, as you see in the first screenshot.

One workaround is to rename all bands: 01_Sigma0, 02_Sigma0, but this takes very long and is a quite unnecessary step.

This might be related to the SNAP-933 issue. At least sounds similar.

that’s possible, yes.

For those who have the same problem. As stated above, a solution is to rename the bands, for example like this:

1 Like

Dear sir

Here you are using processed images to train the raster.

Means, is it the solution to train the raster while doing random forest classification, when we don’t have training data(ground truth data) ?

if it is not can you please suggest me, how to train raster when we don’t have ground truth or training data ?

Regards
D K Rao

To not struggle with the names I collocated the products. By this way snap automatically renames them but when I try to do Random forest classification it gives error: “bounds must be positive”

how can I solve it?

thanks

this error occurs when the data is in UTM coordinates: "bound must be positive" error in the Random Forest Classifier

I did as you described but gives the same error:

By the way, when I start RF classification it gives this warning:

I tried collocation with two products: one S1 product and one reprojected NDVI product. I can open their bands but inside collocate product, I can’t open bands. Maybe this is the problem.

check in the Properties of the NDVI raster, something must link to the flags (probably the valid pixel expression) and you can update or remove it.

Maybe the polygons are still in UTM coordinates? This error always occurred with UTM coordinate systems (mostly the rasters).

three properties windows above are bands after reprojection

three properties windows below are bands before reprojection

Is there any problem?

Probably an old entry in the metadata, but unfortunately not editable in the Properties.

Instead of Collocation, have you considered “Create Stack”? It allows to put multiple products (reproject S2 to WGS84 first) and you could maybe avoid all the mess with the naming and metadata artefacts.

I created shape files in QGIS as below:

So it looks polygons are in WGS84 system.

yes I tried and it worked for two products. But this time I think I will have to rename many bands as you did in RF classification before.

I tried to classify only two images (One S1 and one NDVI). I stacked, renamed all the bands but still gives error.

did you save the product after you renamed the bands?

You can open the DIM file in a text editor and search for this term. If it occurs multiple times, try to rename it there as well. But make a backup of the dim file first.

But when I try it only with S2 and NDVI it works

Yes I saved, closed and opened again. then tried classification.

The term occurs 5 times inside DIM file. But some of them are related to the band description. If I change their names it will probably not identify the band.

which ones should I rename?

none of them should cause the error acutally.
Try renaming them which have no number before it (the actual new names)

I renamed last two Sigma0_VH_db as 03_Sigma0_VH_db and tried classification, it gives this error: