I'm trying to merge 4 rasters I have in order to create mosaic.
However, when I merge them, I get white stripes on the area where they overlap,despite the fact that one of them has non-null values on the overlap parts.
Using the method parameter with value "max" did not solve the problem.
This is how I did the merge:
mosaic, output = merge(tiffs,method='max') #I have also tried just for case : min, last,first
The results have the stripe on the middle:
When I checked if the layers overlap, by getting their extent polygon using qgis, I realized that they do:
I don't understand why I get this stripes, why method doesn't solve it,and how can I avoid this white stripe.
Edit:
Just to give some more information:
- The nodata value set to None
- I took two rasters out of the 4 and created an image to demonstrate what is hapenning on the "white stripes" area:
The cyan polygon is the extent of the bottom raster and the red polygon is the extent of the high raster.
The bottom (cyan) raster, which I don't show in the image, has values inside the polygon (no no-data).
The "red polygon" extent raster has no data values on the bottom.
the red raster with its' extent:
the cyan raster with its' extent:
based on that I tried to set the no-data values to 0 and then to set method to max but that yield the white strips (a bit different style but same problem) –
The result merged raster looks like this (with the original rasters extents on cyan and red):
So it seems like the values of the cyan raster are being removed for some reason I don't understand yet.
Best Answer
For now, I have found a workaround to solve the problem.
I found out that using "max" method doesn't work because there are null values.
Therefore, the solution I found is:
-open the raster
-read as array
-convert no data (null) values into int (for example 0)
-save the new tiff with the int values
-merge the new tiffs
That solved the issue of the overlapping rasters.