I am trying to classify a S2 image. I have resampled the original S2 image, extracted a subset, and identified training areas as vectors. I then reprojected the image. At this stage everything seems OK (I have done this in the past with other S2 images). But after running a supervised classifier (I tried 3) the LabeledClasses band in the new product is void (all pixels assigned to the ‘no data’ label). Can someone help me please?
Can you answer the following questions?
- What classification algorithm did you use? (is it Random Forest from SNAP)
- How did you collect training data? (did you use the tool provided in SNAP to draw polygons or you did that in QGIS and then imported the shapefile in SNAP)
- What parameters did you choose for your classifier?
It would be nice if you could post your results as well
thanks for your message. Answering your questions…
I tried Random Forest, Maximum Likelihood and Nearest Neighbour
The training data was collected on SNAP, using the vector editing tools (rectangles)
For the classification, I selected the classes, identified as vectors, and selected bands 2 to 8 on S2.
This is the reprojected image with vectors (seems to be fine)
The knn classifier window, before the run
did you digitize the vectors before or after the reprojection?
I digitized the vectors before the reprojection. I followed this processing sequence: Original image ; subset ; resampling ; identify classes and vectors ; reprojection ; classificaction.
could you please check if the classification works if you digitize features after the reprojection?
Simply create a copy of your data (Save as…), then delete all geometries, save again, and digitize some new vectors (they don’t need to be precise), and run the classification again - just to test if this is part of the error.
I tested with the vectors identified on the reprojected image, and it did not work either.
can you please share the product ID of the S2 image you are using?
What coordinate system did you use?
The S2 image Id is
In the reprojection stage, I kept the default values - projection Lat/Lon (WGS 84)
I downloaded your image, followed the same steps (slightly different order), but received the same result
I also tried it again without the reprojection step (your area has negative coordinates) but also, no luck. Very strange…
Thank you so much. At least I now know that it is not something wrong with my procedures. I did this type of work several times in the past, and had no problems. The urgency now is that I have a group of MSc students to ‘entertain’ on Saturday morning, and this was the test image…
oh, I can relate very well
The mistery is solved. The problem was due to the lack of data in some of the bands (5-7) on the S2 original dataset. As the classifier was called using these bands, the output was void. Using the same dataset but considering only the valid bands (2-4 and 8) for the classifier, it works fine.