I have two geotiffs related to one location but with different areas covered:
How can I intersect their opaque parts into single geotiff like that?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Note: This solution is working for single band image only
If you have multiple bands, you may repeat this for each band adding
-B_Band options and then
gdal_merge.py -separate the bands.
You should be able to do this:
(We assume NoData Value of your rasters is
gdal_calc.py -A file1.tif -B file2.tif --NoDataValue=0 \ --calc="A*(A>0)+B*logical_and(A==0,B>0)" \ --outfile=outfile.tif
A*(A>0): if A is not Nodata, will be
B*logical_and(A==0,B>0): if A is NoData and B is not Nodata, will be
(This will always prefer A over B).