For several reasons, I need to process with my own scripts the .hdr/.img contained in the BEAM-DIMAP format used by SNAP.
Then I would like to reimport the data to the corresponding BEAM-DIMAP. What I do now is :
drag’n drop the .dim into SNAP Deskstop
drag’n drop the .hdr into SNAP Deskstop
use the Band Maths in SNAP Deskstop to create a new band for the BEAM-DIMAP file whose expression is simply the band of the second product (the .hdr one)
However, I would have liked not to do this manually, by using the Graph Procesing Tool (GPT).
First of all, the BandMaths documentation (gpt -h bandMaths) is not very exhaustive. Ok no problem, I can make the process using the graph builder and create a corresponding .xml file that i can call using GPT. However, the expression editors are different. In the graph builder, I cannot choose the other product’s band.
My last chance was using the “Merge” option. Maybe i’m doing wrong but i’m getting the message "Error: Product [sourceProducts] is not compatible to master product."
Do you replace existing bands? If so, you could simply copy the files into .data directory and replace the existing ones if you haven’t changed the data type. If these are newly generated bands you are on the right track.
It is true, the Band Maths within the Graph Builder does not support multiple bands at the moment. This will change in the next releases.
That the Merge does not work is probably due to the reason the one is geocoded and the other not. Set the parameter geographicError to NaN. Then it should work.
For the BandMaths operator I’ve attached an example how you can reference the first and the second product. BandMaths_twoProducts.xml (623 Bytes)
The Merge with -PgeographicError=NaN works great. However, it adds the band from the .hdr file as “Band_1”, meaning that if i want to merge several times some new products, the Merge function erases the previous “Band_1”. I can’t find a “rename” module or something to avoid the issue.
From the BandMaths, it works great too but it creates a new BEAM-DIMAP file, instead of adding it to the previous one.
One solution is to convert and rename the hdr to BEAM-DIMAP using the BandMaths module and then use the Merge module. Not elegant but works
This should be considered when you read the files in with SNAP. Maybe you can add this already in your other software. If the name is not given, it is simply named as Band_1. The merge is best used when you write a graph file for it.
then you can use the include section.