This model is kindly provided by our Partner GEOSYSTEMS in Germany.
The Sentinel-2 data long filenames and big package sizes have caused problems for many data users. Therefore since September 2016 (shortly after the release of ERDAS IMAGINE 2016 v16.1 which introduced a direct-read capability specific to the older Sentinel-2 format) data started being distributed in single-tile packages with an updated product naming. The naming of folders and files inside the product structure has been compacted to overcome the 256 characters limitation on pathnames imposed by Windows platforms. The issue with the direct-read raster dll will be fixed in ERDAS IMAGINE 2017.
In the meantime, GEOSYSTEMS has created a Spatial Model as a solution for ERDAS IMAGINE 2016 and v16.1.
This model allows users to:
The model consists of the main model and four sub-models. The main model is used to access the single raster files for each band. Each filename will be derived from the “.safe” directory selected by the user (1).
The FindFiles sub-model (2) searches for all *.jp2 files within the Sentinel-2 data directory. The filenames are passed to corresponding Raster Input operators (3). The 3 stack sub-models (4) are used to create the stacked file for the selected resolution by using a Stack Layers operator on all 10m, 20m or 60m bands.
The creation of the Virtual Stack (VSK) file is done by using the Report operator (6). The internal structure of a VSK is quite simple. The first line consists out of the entry “VSK”. This is created as static text. Each following line contains the full path to the input file. In our case those files or single bands *.jp2. Since we do already have the full input filenames we can use them to generate the VSK references to the single bands. The filename for the vsk is automatically generated out of the chosen input directory (sub-model 2). A Boolean input port (7) connected to an additional “If Else” operator allows the user to enable or disable the VSK generation.
Each of the three Stack sub-models contain an If Else operator which allows you to pick which of the three (can be all, or even none) files will be generated. The user is prompted to enter three output filenames by using Port Inputs (5). Each of those port inputs is connected to the Test port of the If Else operator. So, if the user provides an output filename, the stream is true and the branch of the model connected to the True port will be executed. If the user does not enter a filename, then the test will return false and so the False port branch will be executed. In this case there is nothing attached to the False port so nothing is executed, therefore no file created.
|Stack 10m bands sub-model|
|Stack 20m bands sub-model|
|Stack 60m bands sub-model|
In the FindFiles sub-model we access the selected input directory (1). In order to find the image files we manually add the “GRANULE” folder name inside of the *.safe package to the path (2). Now we are able to search for all *.jp2 files in this folder and its sub-folders using the “Multi Filename Input” operator (3). The result is then stored in a list that allows us to pick the correct entry for each band of Sentinel-2 data (4).
The sub-model is also used to generate the VSK (Virtual Stack) file name by splitting the input directory path and selecting the *.safe directory (5). The “Get Basename” function removes the *.safe extension (6) and now we add the full input directory path plus the *.vsk extension to the string (7 and 8).
Safe-Directory: User defined input directory of a *.safe file under which the model will search for data.
Output File for 10m bands: filename of output image with all bands at 10 m resolution.
Output File for 20m bands: filename of output image with all bands at 20 m resolution.
Output File for 60m bands: filename of output image with all bands at 60 m resolution.
Create Virtual Stack: True or False option for creating the Virtual Layer Stack file (vsk) containing all 13 bands with its native resolution. If set to True the *.vsk file will be created in the location specified on Safe-Directory input port.