Hexagon Geospatial
MENU

Spatial Modeler Tutorials

Learn more about our products, find answers, get the latest updates, and connect with other Hexagon Geospatial product users, or get support from our professional service team.
Showing results for 
Search instead for 
Do you mean 

Sentinel-2 Stack / Import

by Technical Evangelist ‎01-10-2017 11:40 AM - edited ‎01-10-2017 11:48 AM (3,951 Views)

Download model

 

 

This model is kindly provided by our Partner GEOSYSTEMS in Germany.

 

GEOSYSTEMS_2015_RGB_72dpi.png

 

Description:

 

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:

 

  • stack:
     
    • All bands with 10 m resolution
    • All bands with 20 m resolution
    • All bands with 60 m resolution
  • create a Virtual Layer Stack file (vsk) containing all 13 bands with its native resolution

 

 

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.

 

stacksentinel2.gmdx
s2_1.png

 

 

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
s2_2.png
Stack 20m bands sub-model
s2_3.png
Stack 60m bands sub-model
s2_4.png

 

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).

 

FindFiles sub-model
 s2_5.png

 

 

Input parameters:

 

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.

 

 

s2_6.png

 

 

Comments
by Technical Evangelist
‎01-18-2017 05:47 AM - edited ‎03-30-2017 08:01 AM

Hexagon Geospatial has recently completed work on a Hotfix for ERDAS IMAGINE 2016 v16.1 to address the issue of the altered Sentinel-2 formatting. If you would like to utilize the updated software in order to be able to directly read the updated format please visit the Download section of our website:

 

http://download.hexagongeospatial.com/downloads/imagine/sentinel-2-data-hotfix

 

Note that using the direct-read capability avoids any decompression / recompression issues associated with the original JPEG 2000 encoded data.

 

Please also remember that Sentinel-2 images consist of a mixture of differing pixel resolutions. These can be accessed at their native resolutions (and in different groupings) through use of the Sub-Images tab of the File Chooser when opening the SAFE dataset.

 

safe.png

by totor
on ‎12-10-2017 08:46 PM

On XP platform, when attempting to Ioad the Spatial Model stacksentinel 2.gmdx, I got an error message:

''Could not load Spatial Model c:\program files\intergraph\erdas imagine 2014\etc\models\stacksentinel2.gmdx''.

 

I presume this is a downwards compatibility issue of ERDAS program. Is there a way to fix this, without having to upgrade to ERDAS 2016 or higher ?

 

Thank you,

 

totor

 

Courses
Contributors