Sentinel-2 problem with Land/Sea mask tool

Hello everyone,

I have problem with masking Sentinel-2 images. I can open image in RGB window and import .shp file which defines my area of interested, but after using Land/Sea mask tool I receive all the extracted bands entirely black - even inside of the mask. Does anyone have problem like that or someone know good way for creating subset of snap images with .shp layer? I can’t use existing subset tool because I need to cut irregural shape, not rectangle.

did you check if your shapefile is projected in the same coordinate reference system?

Yeah, it is, I’ve just checked. I thought for a while that the problem is that one part of the S-2 image is in UTM 33N zone, but another part in UTM 34 zone, but I also tried to mask it not with a external shapefile, but with polygon drawn in SNAP - I still receive totally black image after using land/sea Mask.

strange. Is your S2 data resampled to a common resolution?

Do you mean if I resampled all bands to one size of the pixel? I need only bands 2,3,4 and 8 and these have the same spatial resolution. Do you think I shall resample all bands even that and try to mask all of them?

you could make a band subset with a product that only conains these three bands and then try to mask again.

I need to resample bands before making band subset. However, I still don’t receive expected results. By the way - I can succesufly mask Sentinel-1 imagery with Land/Sea mask even if shapefile layer is in another coordinate system, so I think there is another reason that things don’t happened…

Did you (or could you) check if your SNAP instance is able to mask Sentinel-2 data with shapefile?

I tried it myself and can confirm that it didn’t work.

Problem solved!

It is necessary to do Reprojection before using Land/Sea Mask. Strange, because even before that shp layer is showed in suitable place in the view.

However, with processing path as follows, everything is correct:

  • Resampling (demand by SNAP even if you finally need only bands with the same spatial resolution, f.e. 2,3,4)
  • Reprojection
  • Import vector layer
  • Land/Sea Mask.

Finally, it was connected with CRS, so thank you for inspiration and motivation!


great to hear that there is a solution. This will surely help others as well, thanks for reporting.

Hi @mkubicki,

I had exactly the same problem. When you talk about reprojection, do you mean to reproject the S2 image to the same CRS that already has or reproject the shp?


Hi @MCG,

I don’t know if I good understood you. Are you asking if I reproject my Sentinel-2 imagery to exactly the same coordinate system as it’s deliver (UTM) or if I reproject the imagery to the same coordinate system as my shapefile with AOI?

Hi @mkubicki

I created my shp using the UTM projection that my S2 image has. So both my S2 image and shp have the same projection at the begining of the methodology. However, same as for you, the masking process is producing an empty product. I am trying your solution and would like to know if you re-projected the S2 to the exactly same coordinate system as it’s deliver (I know this is redundant)

I’ve managed to have the correct result by following the methodology of @mkubicki. Just a clarification for new readers, the reprojection is for the S2 image (assuming that both your shp and S2 image have the same CRS). So, if you want to crop an image with the exact shape of your study area, you will need to reproject the S2 before.

1 Like