I have a subset of a resampled Sentinel 2 L1C .SAFE product. I want to export the whole subset product (e.g. all 12 bands) to Geotiff, how do I do this?
I believe is the input product in BEAM-DIMAP format because I have succesfully saved the product before. File export seems to be the logical choice, but it seems to save everything into 1 unreadable TIF file, as opposed to a folder with 12 different bands in TIF format.
(Note: when taking a subset I was also given the option to save to Geotiff, I did not do this because this took too long and gave errors, so I simply used ‘Open in SNAP’ which worked)
Geotiff yielded a 0 byte file (SNAP didn’t seem to process anything, so I stopped it). Bigtiff worked, it took about 10 minutes, and indeed gives a 5.8 GB file (over the max Geotiff size, so that might make sense). So I understand that 1 file is intended, and I managed to open the file in QGIS and it seemed to work. I also opened it in Photoshop, this gave a white screen (maybe because its a Bigtiff, and not a normal tiff). Is there still a way to separate the bands? This would make processing easier.
I also want to check the Bigtiff raw pixels to see if they are 16uint, I have noticed some software writes pixels as 32int or 32uint, and therefore takes up unnecessary space.
Separating the bands in the GUI is a bit cumbersome. It might be ok if you want to do it only for a single product.
You can do a subset for each band and store them as single tiff files
But you can do it also with graph builder or gpt on the command line.
I’ve attached a graph file which you can use on the command line. Currently it writes only B1 and B2. But you can copy and adapt the BandSelect and Write nodes for the bands you need.
In the header of the file is an example command line call. The directory where you want to store the data musst already exist.
Thanks for the speedy reply, I have tried to implement your suggestion, but I encountered some errors, its seem my SNAP is missing the BandSelect operator. I also tried to implement it in gpt this yielded a similar error. Just to note, I am using version SNAP 5.0.
Maybe The BandSelect is coming with S1TBX. You can replace ist with the Subset operator and define a single band as subset. Unfortunately I have not much time to provide a new example. I hope you can go on.
Thanks, the BandSelect being part of the S1TBX I believe solved it. I reinstalled SNAP with all toolboxes. I tested the graph on 2 bands and it worked well, I will now test it on all 13. I also checked the Geotiffs with gdalinfo command and the data was written as 16uint so that is also nice.
Good to hear that it now works. As an additional note, you can install additional toolboxes after installing SNAP by using the plugin manager.
Regarding the data type. In Tiff it is necessary to use a common data type. So we have to use the one which can hold the data of all bands.
I am having problems resampling and subseting Sentinel 2 L2A images. I am trying to resample all the bands to 10 m and then create a spatial subset but snap doesn’t let me save this last products and it gives me an error saying that the resampling should be done first even though it has been created already virtually. I am trying with band 8A. So first I resampled the complete product and from the virtual product I made a subset and now I want to save it as geotiff. And I get this error.
I need to have a raster with all bands with the same cell size to use it for further processing.
Could you please tell me how did you do it? I appreciate very much your help.
This is related to a bug (SNAP-686) I work on at the moment.
To get around this issue you can either delete all masks contained in the product or you save the subset first to BEAM-DIMAP and then read it in again and then export to GeoTIFF.
Thank you very much for your reply. I was able to make it work with one band like you said. First subset to BEAM-DIMAP and the export to Geotiff. How to delete the masks? I would like to try this option because saving my resampled product takes a lot of time, it is a whole tile 33UUB.
Just select one or multiple masks in the Product Explorer and press the ‘Del’-Key or chose from the menu Edit / Delete
To make deletion process easier you can remove the grouping of the masks. To do so, open the context menu by right clicking on the product and chose Properties. Find the entry ‘Band Grouping’ and open the editor for this field by clicking on the button with the periods on the right.
Remove everything after ‘view’
I just noticed that when I open the resampled subseted band in arcgis I still get a cell size of 20m instead of 10. But checking the metadata of the band it says that the pixel size is 10 by 10. Do you know why this might be?? Also trying NN resampling in arcgis with the same band doesn’t work, I still get a pixel size of 20 m when measuring and a pixel size of 10 by 10 in the properties of the band. It only works when performing bilinear resamapling that I am able to measure the pixel and get 10m and matches with the metadata. Any idea why this is? I measured the pixel size in snap before exporting to tif and it was correct. But once opened in arcgis this is not coherent.
I guess you are absolutely right and I am measuring 2 pixels. I understand the difference between NN, bilinear or cubic i just didn’t realize that I might have been measuring two pixels and I was trying many things to understand why.
Thank you very much, you made my day!