Train supervised classification algorithm on multiple Sentinel-2 tiles (i.e. multi-temporal classification)?

I am using the Maximum Likelihood Classifier in SNAP and would like to train it on multiple Sentinel-2 tiles and then apply it to a new tile that is hasn’t seen before. For example, I would like to train it on observations made on 1 July 2016 and 1 August 2016 and then apply the trained classifier on an observation made on 1 September 2016. Note these observation times would all correspond to the same spatial region (or tile).

Is this possible? Or does SNAP only allow for training a classifier on a single image?

I don’t think that you can technically “merge” a training dataset from multiple scenes in SNAP because the number of input bands (for the training) and the bands of the raster to be classified must be the same.

Thanks for the response - perhaps this could be a new feature to add to snap? I don’t see why the number of input bands and bands of the raster to classify would have to be different in this use case.

You could train say an urban class using B2, B3, B4 by drawing a vector polygon over a specific area (say a city). Then you add to this training set by using the same polygon but for observations at different times. This way the number of bands (features) remains the same but the training data increases. Does that make sense?

You can have a look at the Semi Automatic Classification plugin in QGIS. It is able to do what you need because it allows you to switch between various input rasters and merge taining areas.

It is very well documented with lots of videos and manuals.

I believe the answer I’m looking for is here: Multi-temporal Random Forest - NaN pixels

More details here:

However, when I try to run the classifier I get the following error:

Error: [NodeId: Maximum-Likelihood-Classifier] Cannot select feature band B1 in more than one product

I’m using SNAP version 6.0.4


I think that currently it is not possible to select bands with the same name in different products. If you want to do that, perhaps you could change the name in the properties of the band or you could make a collocation in order to add a suffix to the name of the bands.

Ah ok thanks. I tried renaming the bands and this works - which is fine for 2 products but this process becomes a bit tedious for 5 products as I have to right-click, go into properties and change the name of every band in every product. This process is very inefficient.

Do you know if it’s possible to put in a feature request to solve the issue of the same named bands in different products?

I assume I would encounter the same issue with the collocation approach as this only allows you to collocate two products at a time.

That’s the right way for feature requests. To report them here in the forum.
I’ve created a ticket for this problem. You are right this is annoying. (SNAP-933).

If you need to do this repeatedly you could write a graph XML which is doing the renaming.

Regarding the collocation. You could call it multiple times and collocate this way multiple products. But currently, it is intended for two products, that’s right.
If your products already have the same extent, you can use the Merge op on the command line.

1 Like