Sentinel 2 Preprocessing

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:

  1. resample all bands to 10 m
  2. spatial and bands subset
  3. 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!

 

Prerequisite

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!

Here you can download Sentinel-2 level 2 data (from 31th of July 2018) for execute this exercise.

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.

Open File SNAP

 

Use SNAP’s toolbar to navigate to Raster > Geometric Operations and open the Resample operation:

Navigation to Resample

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.

Resampling settings tab 1

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 :

Resampling settings tab 2

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:

Virtual product notification

Close the Resampling tool.

With a right click on the processed image (product) > Open RGB Image Window you can open differnet band combinations:

Open as RGB Image

 

Navigate to the Subset function:

Subset function in Toolbar

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:

Subset function settings

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:

Export function

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:

Export function settings

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: