Merge or stitch tiles in batch?

Frequently Asked Questions
juliana.tavora
Posts: 8
Joined: Sun Jan 10, 2021 11:39 am

Merge or stitch tiles in batch?

Post by juliana.tavora »

Hello Quinten,

Is there a way to merge/stitch tiles in batch?
The only way I found possible to merge the S2a,b scenes I have was by processing each group of scenes to merge at a time (as in the manuals example).
But is there a way to just leave the full comma separated sequence of scenes in the input and to process in batch?

Thanks in advance
quinten
Posts: 1021
Joined: Tue Mar 03, 2015 8:13 am

Re: Merge or stitch tiles in batch?

Post by quinten »

Hi Juliana

To do a batch run of merging tiles you will probably need to run your own batch processing of sets of tiles you want to merge. I can provide some help with that - if you can let me know which system and version of ACOLITE you are using.

If you are using the GitHub version this is pretty easy, and can be done in a Python script. If you are using the binary release you'll have to make a simple batch script and provide ACOLITE with sets of tiles you want to merge.

I could probably also change the way the text file passed to --image when you launch ACOLITE is parsed, to allow for sets of images to be processed with merging.

Quinten
juliana.tavora
Posts: 8
Joined: Sun Jan 10, 2021 11:39 am

Re: Merge or stitch tiles in batch?

Post by juliana.tavora »

Hello Quinten,
thanks a lot for your fast reply!

I am using the latest version of acolite (v. 20190326.0) on cli-way on a windows OS.

My knowledge of python is still very limited to the basics, any insight from you will be a life saver.


Thanks
quinten
Posts: 1021
Joined: Tue Mar 03, 2015 8:13 am

Re: Merge or stitch tiles in batch?

Post by quinten »

Hi Juliana

To run a batch of merging scenes in Windows you can use a .bat file. I have made a simple example to launch ACOLITE processing for a number of scenes. You can paste and edit the following example in notepad and save it as e.g. acolite_merge_batch.bat This file should then execute the batch processing when you double click it.

You will have to edit the variables, ac_dir to point to the location of your acolite_py_win directory, settings to the settings file you want to use. Make sure to use full system paths.

The images variable contains a list of strings with each string the set of images to be processed. For example if you have 4 image pairs you would have images="image1a,image1b";"image2a,image2b";"image3a,image3b";"image4a,image4b" Here the quotes around each image pair make sure that the pair is passed to ACOLITE as the images to merge, the semicolons make it a list that Windows can use in a FOR loop. I add each image pair on a different line for legibility.

The sample code:

Code: Select all

SET acolite_dir=\path\to\acolite_py_win
SET settings=\path\to\settings.txt

SET images="\path\to\image1a,\path\to\image1b"
SET images=%images%;"\path\to\image2a,\path\to\image2b"
SET images=%images%;"\path\to\image3a,\path\to\image3b"
SET images=%images%;"\path\to\image4a,\path\to\image4b"

@ECHO OFF
cd %acolite_dir%
for %%i in (%images%) do (
 echo Processing %%i
 dist\acolite\acolite.exe --cli --settings=%settings% --image=%%i
 echo/
)
ECHO Batch completed.
PAUSE
Let me know if this works for you!

Quinten
juliana.tavora
Posts: 8
Joined: Sun Jan 10, 2021 11:39 am

Re: Merge or stitch tiles in batch?

Post by juliana.tavora »

Hello Quinten

Works perfectly, thanks a ton!

Juliana
juliana.tavora
Posts: 8
Joined: Sun Jan 10, 2021 11:39 am

Re: Merge or stitch tiles in batch?

Post by juliana.tavora »

Hello Quinten,

I have just downloaded that new version of acolite. Really cool new tools!

I am now trying to figure it out how to set merging files in batch (like used in this topic) using the new acolite cloned from github.
Like on that previous example (which that helped me a lot), I am using a windows OS, with the github version on the windows terminal (+ not using conda).

Any insight will be beyond helpful,

Thanks in advance
quinten
Posts: 1021
Joined: Tue Mar 03, 2015 8:13 am

Re: Merge or stitch tiles in batch?

Post by quinten »

Hi Juliana

In the new version I renamed the --image flag to --inputfile in the ACOLITE launcher, so probably changing this line

Code: Select all

 dist\acolite\acolite.exe --cli --settings=%settings% --image=%%i
to

Code: Select all

 dist\acolite\acolite.exe --cli --settings=%settings% --inputfile=%%i
may do the trick... Could you check if this works for you?

Quinten
juliana.tavora
Posts: 8
Joined: Sun Jan 10, 2021 11:39 am

Re: Merge or stitch tiles in batch?

Post by juliana.tavora »

It is working perfectly now Quinten.

Thanks a ton!

Juliana
marloesvaessen
Posts: 4
Joined: Wed Mar 16, 2022 10:13 am

Re: Merge or stitch tiles in batch?

Post by marloesvaessen »

Hi Quinten,

I'm currently using the GitHub version of ACOLITE for my bachelor thesis and ran into an issue when trying to run in batch mode, as the tiles did not seem to merge at all. I have attached the input and settings file I used and an example of a non-merged image I got out. I'm running ACOLITE on a Linux operating system.

Could you tell me where I went wrong?

Thank you in advance!

Marloes
Attachments
S2A_MSI_2021_12_21_10_57_00_merged_L2W_SPM_Nechad2016_865.png
S2A_MSI_2021_12_21_10_57_00_merged_L2W_SPM_Nechad2016_865.png (261.02 KiB) Viewed 120065 times
input.txt
(757 Bytes) Downloaded 616 times
acolite_python_settings.txt
(5.44 KiB) Downloaded 583 times
quinten
Posts: 1021
Joined: Tue Mar 03, 2015 8:13 am

Re: Merge or stitch tiles in batch?

Post by quinten »

Hi Marloes

Are you running a recent clone of the latest GitHub code, and are you running the GUI or CLI? Are you sure the scenes are complete and accessible via the provided paths? (e.g. does processing this list of scenes provide 4 separate files when running with merge_tiles=False?)

I usually provide the full paths to the scenes to avoid problems. For me the merging works here with a simple settings file like this, note the inputfile is a comma separated list of full paths to where the files are on my system:

Code: Select all

inputfile=/media/quinten/DATA_S2L8_L1_A/Sentinel-2/Data/31UDS/S2A_MSIL1C_20211221T105451_N0301_R051_T31UDS_20211221T125433.SAFE,/media/quinten/DATA_S2L8_L1_A/Sentinel-2/Data/31UES/S2A_MSIL1C_20211221T105451_N0301_R051_T31UES_20211221T125433.SAFE,/media/quinten/DATA_S2L8_L1_A/Sentinel-2/Data/31UET/S2A_MSIL1C_20211221T105451_N0301_R051_T31UET_20211221T125433.SAFE,/media/quinten/DATA_S2L8_L1_A/Sentinel-2/Data/31UDT/S2A_MSIL1C_20211221T105451_N0301_R051_T31UDT_20211221T125433.SAFE

output=/storage/ACOLITE/Support/202205/Marloes

merge_tiles=True
limit=51.1,2.2,51.76,4.6

l2w_parameters=chl_re_gons,spm_nechad2016_nir,spm_nechad2016_red,rhos_*
map_l2w=True
s2_target_res=20
S2A_MSI_2021_12_21_10_57_00_merged_L2W_SPM_Nechad2016_665.png
S2A_MSI_2021_12_21_10_57_00_merged_L2W_SPM_Nechad2016_665.png (515.11 KiB) Viewed 120061 times
Let me know how it goes!

Quinten
Post Reply