Sentinel 2 data is delivered as zip-compressed files in Sentinel’s own SAFE format. The spectral bands are stored as jpg-files in this SAFE container in three different geometric resolutions (10 m, 20 m & 60 m as shown in Section Sentinel 2). We want to stack these jpg-files into a single geotiff-file of an uniform pixelsize of 10 m, i.e., into a so-called raster stack (because it is much easier to work with such a raster stack).
Due to the size of the data, we need to subset the important data from the SAFE container during preprocessing in order to minimize the computational time and the data volume. Otherwise, a single Sentinel 2 image can quickly grow to 8 GB in size! For this, we will use only desktop app SNAP and its commando-line based counterpart, the Graph Processing Tool (GPT). This results in the following intermediate steps:
- resample all bands to 10 m
- spatial and bands subset
- save image as geotiff/ bigtiff to hard drive
We want to perform the preprocessing step by step on the basis of an Sentinel 2 Level-1 scene in SNAP. Based on that we will develop a graph file that will process an arbitrary number of scenes for you!
The following content requires that you have either successfully downloaded some Sentinel 2 scenes as part of the Download Section Exercise, or that you have acquired some datasets from the ESA SciHUB by your own. If this is not the case, look into the chapter Sentinel / SciHUB!
Done? – Then start SNAP now!
Preprocess a single dataset
If SNAP is started, you can open the zip file of an image directly by File > Open Product.
Use SNAP’s toolbar to navigate to Raster > Geometric Operations and open the Resample operation:
A window will pop up with two tabs. In the first tab, define a downloaded, zipped Sentinel 2 file as the source product. You do NOT need to unzip it in advance! In the example shown below, the file is located in the exchange folder of our VM.
Click on the second tab “Resampling Parameters”. Select spectral band 2 here to define the geometric resolution of the final product (band 2 has a resolution of 10 m) and press :
This should create a “virtual file” with the suffix “_resampled”, which is not stored physically on your hard drive. The advantage is that no computationally intensive processes have taken place here and we can continue to calculate with the intermediate product, which should be listed in the Product Explorer in SNAP. You will also get a notification about this. Confirm this with OK:
Close the Resampling tool.
With a right click on the processed image (product) > Open RGB Image Window you can open differnet band combinations:
Navigate to the Subset function:
The subset function allows you to perform both spatial and spectral resampling. By excluding irrelevant data, you can reduce the volume of data by several orders of magnitude. In the example shown below, we do a spatial subset based on geographic coordinates and only select specific bands:
By pressing OK, another data product with the prefix “subset” is generated within a second and should be visible in the Product Explorer in SNAP. Select the newly created data product in the Product Explorer by a simple left-click on it and navigate through the toolbar to File > Export > GeoTIFF, as shown in the next screenshot. If you notice that your file is larger than 4 GB, you can also choose BIGTIFF as the target file format. BigTIFF describes a GeoTIFF file that is over 4 GB in size. However, saving a BiTIFF file in SNAP is very slow, especially for machines with only 8 GB of RAM. Therefore try to use the GeoTIFF file format first:
In the window of the export function you can then define the file path and the name of the exported file. Then press Export Product to start the processing:
The processing will take some time from now on, based on the spatial subset and the number of bands you selected.
Here you can watch all presented pre-processing steps of Sentinel-2 data: