I am working with Sentinel-2 data, which I want to collect for a ROI that unfortunately is covered by two different (neighboring) granules. After downloading the granules, I cut them and convert them to to GeoTiff using
gdalwarp -of GTIff -crop_to_cutline -cutline cutline <10m_input_bands> datasetname_10m.tif
This gives the corresponding 4-band GeoTiffs (which contain only the 10m bands 4,3,2 and 8), including lots of no-data pixels where the ROI is actually located in the neighboring granule.
After that, I want to merge them by
python gdal_merge.py -of GTiff -o mergedImage.tif inputImage1.tif InputImage2.tif
The result, however, seems to be just a copy of inputImage1.tif, i.e. the no-data values remain and no mosaic is created.
What am I missing? Or is there another way to create coherent Sentinel-2 ROI images extracted from neighboring granules? At best, this would be automated for batch processing, i.e. search for products of similar name where only the granule indicator (e.h. UPU, UQU etc.) changes, and then performs the merging automatically.
EDIT: Maybe this was clear already, but to be sure: Since the output of gdalwarp is already corresponding to the ROI, the images are of the same size and follow the same geocoding reference (i.e. they reflect the same spatial subset).
-n
switch could help.