<div dir="ltr"><div dir="ltr">Hello Steven, <br><br>Thank you for your reply. I should have mentioned that my ultimate goal is to mosaic more than two images, so I don't know if the workflow that you suggest would work in that case. I did use your suggestion of masking values, and changed the VRT python function to this:<br><br>import numpy as np<br><br>def average(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize,raster_ysize, buf_radius, gt, **kwargs):<br>    x = np.ma.masked_greater(in_ar, 100)<br>    np.mean(x, axis = 0,out = out_ar, dtype = 'uint8')<br><br><br>That worked, but now I have a new issue. I want to try a maximum function instead of mean to evaluate if the resulting mosaic would look seamless, I tried this: </div><div dir="ltr"><br></div><div dir="ltr">import numpy as np<br><br>def average(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize,raster_ysize, buf_radius, gt, **kwargs):<br>    x = np.ma.masked_greater(in_ar, 100)<br>    out_ar[:] = np.ma.max(x, axis = 0, fill_value=0)<br><br>The max function works fine in areas where there is data, but for some reason, areas of overlapping NA values result in a pixel value of 63. I tried setting the fill value of the masked areas to zero but that didn't work. I appreciate any suggestions. <br><br>Kind regards, <br><br>Adriana.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 24, 2019 at 7:38 PM Adriana Parra <<a href="mailto:adrianaparra@nevada.unr.edu">adrianaparra@nevada.unr.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello, <br><br>I have been trying to mosaic two images that partially overlap using band pixel functions in Python. My images contain unsigned integers (uint8) and the no data value is 255. I considered using the nanmean function so that I would get average values in overlapping areas of the two images and maintain the original value of the non-overlapping areas, but for some reason the NAN values are being interpreted as zero, resulting in half of the original value in non-overlapping areas.  I would really appreciate any feedback. I am using GDAL 3.1.0 and python 3.6. Bellow is the code I used and I am sending attached the input files.<br>gdalbuildvrt  mosaic1.vrt -input_file_list  input_files.txt -srcnodata "255"<br><br> import numpy as np<br>def average(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize,raster_ysize, buf_radius, gt, **kwargs):<br>    np.round_(np.clip(np.nanmean(in_ar, axis = 0, dtype = 'uint8'),0,255),<br>              out = out_ar)<br><br>gdal_translate --config GDAL_VRT_ENABLE_PYTHON YES mosaic1.vrt mosaic1.tif<br><div><br></div><div><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;font-family:arial;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/a/nevada.unr.edu/file/d/1YgugcVnU6d5BmPYkYcotqBi3fFQcPpY8/view?usp=drive_web" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration-line:none;padding:1px 0px;border:none" target="_blank"><img style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="vertical-align:bottom;text-decoration:none">Mosaic1.jpeg</span></a><img style="opacity: 0.55; float: right; display: none;"></div><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;font-family:arial;font-weight:bold;font-size:13px;border:1px solid rgb(204,204,204);line-height:1"><a href="https://drive.google.com/a/nevada.unr.edu/file/d/1SQoH58V3MGtP-oXYnPYsf66snFOsWagC/view?usp=drive_web" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration-line:none;padding:1px 0px;border:none" target="_blank"><img style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="vertical-align:bottom;text-decoration:underline">raw_files.jpeg</span></a><img style="opacity: 0.55; float: right;"></div><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;font-family:arial;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/a/nevada.unr.edu/file/d/14No5nblxhNKeOU8k86Gfan7utYIUSqRU/view?usp=drive_web" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration-line:none;padding:1px 0px;border:none" target="_blank"><img style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="vertical-align:bottom;text-decoration:none">test_files.7z</span></a><img style="opacity: 0.55; float: right; display: none;"></div><br></div><div><br></div></div>
</blockquote></div></div>