Export mask to geotif

Hello,

I used Change Detection form SAR Application menu (Sentinel-1 Toolbox). I got a mask (saved as a mask file), which I’d like to export to GeoTiff. In Mask Manager I found an option to export as .xml, however I prefer .tif format. Any hints?

You can select it from the menu File > Export > GeoTiff

When I do it only the band called log_ratio is exported, not mask.

you could open band math and make a band out of the mask.

That works. Thank you.

Which values are stored in the mask? is it 0 for outside the mask and 1 for the mask? I am having trouble evaluating mask values in SNAP.

yes, the mask is 1 where the condition is true and 0 where it is false.

Thank you. Unfortunately I can only create corrupt products after using Mask functionalities. Are there any known Issues with connected to creating masks in SNAP 7?

I have assumed my task is very easy but I have come across several Issues:
Task: creating different classes as training areas and exporting them as Raster Mask layers.

Problem: with the product that I have created masks on I cannot save a correct *.nc and neither a *.tif file. Also *.dim seems to have issues, even though the filesize outputs in the correct range. The only thing that has worked so far was exporting the masks as shapefiles, which is no option, as I need to continue calculating with the rasterlayers.

Do you have any Idea why this could be? I can also describe the Mistakes more narrow in a new thread.

Thanks,

K.

I am not sure if I understood your goal.
You want to select pixels based on a logical expression and export them to .nc or .tif?

Yes and no:

  • I am digitizing training areas from a S2 scene with geometries in the mask manager.
  • my goal is to output these as rasters either in .tif or preferably in .nc (indicating NaN where there is no training area and 1 where there is, resulting in one rasterlayer/band per training area; or alternatively an integer number for each training area, resulting in one rasterlayer with multiple training areas e.g. 1 to 9 and NaN, where there is no training area).
  • I need this as a basis for a logical/thematic selection of the pixels for further using the resulting raster(s) in python
  • I managed to write the masks to bands with Band Maths, however the outputted .nc files were corrupt. I couldn´t check the .tif files yet, because I can´t find a visualization option in SNAP for visualizing two values and the written bands appear all black. Can you let me know how to do this?

I didn´t expect my goal to be too complicated, because the actual rasterizing of the original vectors is obviuosly already implemented, as I understood from your comment on masks.
However I seem to be missing something.
I hope this helps to clarify my goal and I would be happy for a solution.

Thank you and best regards,

Konrad

Have you disabled the “virtual” option during the band maths operation?
It is always good to save the product again after adding new bands befor you export the band maths results.

Yes, for some layers i have disabled it, when I forgot I right clicked on the band using “convert band”. I have a working .dim product that reopens aswell. However due to not being able to display the mask-bands well I cannot check wether the data is correct.

if the mask bands cannot be displayed, there must have gone something wrong during their creation or storage.
It is hard to guess what could be the reason but you probably already tried deleting them and creating the mask bands again and writing them to separate bands in the band maths?

I have just tried it and this works for me:

  1. create a mask (here by a logical expression in the mask manager, but an imported vector should work the same)
  2. write a band (band maths) based on the mask (disable “virtual”)
  3. save the product
  4. Export the mask as GeoTiff (select “subset” then only select the band"
  5. Test the export

I have a similar question to this problem:
I have already created a mask showing floodings of a cyclone.
How do I ascribe the values true = 1 and false = 0 to my mask? I want the flooded area to get 1 and the dry area 0.

You can create a new band using the Band Maths (disable “create virtual band”) and enter the name of the mask as the expression. This will give you a binary raster with 1 = mask and 0 no mask.

1 Like

Thanks! That worked.