Replying to myself to show my last update on the situation...
I have made some interesting improvements:
I am now able to write the full extent of raster `A` correctly over raster `B`, having the same pixel values in the same locations for both rasters.
The only thing left before having a complete solution is that the output raster has some (apparently regularly spaced) stripes, sign that there might be some adjustments to do in the window coordinates translation.
Here is a picture of the updated situation:
zoomed to see the stripes:
Finally, the updated code:
with rasterio.open(inputfile, 'r') as src:
) as mosaic_raster:
for ji, window in src.block_windows(1):
r = src.read(1, window=window)
left, top = src.xy(
right, bottom = src.xy(
row=window.row_off + window.height,
col=window.col_off + window.width)
new_window = from_bounds(
mosaic_raster.write(r, 1, window=new_window)