Split product bandwise into single GeoTiff files

I would like to share an example graph file which shows how to split a product into separate GeoTIFF files.
Each GeoTIFF file will contain only one band. How this can be achieved is shown by the example of a Sentinel-2 product, but the approach can be adapted to other products.

The example reads a Sentinel-2 L1C product, resamples it to a common resolution and then splits and writes each specified band.
Only the bands B1 and B2 are considered in the graph. But it can easily be extended to the other bands just by copying and adapting the pair of nodes BandSelect and Write.

As a comment in the header of the graph XML file is written how the file can be used with gpt on the command line.

C:\Progra~1\snap\bin\gpt "C:\Users\Marco\Desktop\SplitS2_Graph.xml" -PtargetbasePath="G:\EOData\temp\S2A_MSIL1C_20160914T074612S2A_MSIL1C_20160914T074612_N0204_R135_T36JTT_20160914T081456" "G:\S2\newS2Sample\S2A_MSIL1C_20160914T074612_N0204_R135_T36JTT_20160914T081456.SAFE\MTD_MSIL1C.xml"

Fist comes the gpt command, then the path to the graph XML file is specified. Next is the targetbasePath. It is used as the basis for the GeoTIFF files. The band name is appended to the base path within the XML file.
The last parameter is the path to the source product.

Currently, for version 5 and 6 preview, the target directory must already exist. For the final version 6 release, this issue will be resolved.

You can also add a Reprojection node or a Subset node to the graph in order to change the projection or cut out a certain region.
If you want to have the bands in their original resolution, you can add the Resample node three times and use them for the different BandSelect nodes.

SplitS2_Graph.xml (1.8 KB)

8 Likes

Thanks for sharing it!! :slight_smile:

Genius!! Thank you