TransWikia.com

Python GDAL Merge Issue: gdal_merge.py

Geographic Information Systems Asked by terraCoder on February 2, 2021

I am having a Merging issue with the GDAL python library. I am using gdal_merge.pylink

My issue is when I merge two rasters NoData value of one raster overlaps the other data resulting in not a proper raster image.

For example, in the raster images below (left images) if I merge these 4 images labeled as 1,2,3,4 I should get the merged raster image as the right-sided image.

enter image description here enter image description here

But, the merged image I am getting looks like this (image below):

(Note: Image labeled 1,2 and 3 are merged properly. It’s only when we merged them with image labeled 4, it’s not properly merging.)

enter image description here

If anyone knows, how to resolve this issue then it’ll be a great help to me. Thanks in advance.

One Answer

Are you using the -n parameter? If not, nodata values will be included in your mosaic.

GDAL will ignore nodata values if you specify this and will mosaic data without overlapping nodata areas included.

Note (update from OP): np.nan may not work as a nodata value

For example:

gdal_merge.py -n 0 -o output.tif input1.tif input2.tif

You will need to know the nodata value and make sure it is the same in each image

Answered by Nathan Thomas on February 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP