Merge resulting in one pixel shift for half the output file


melda.salhab.14@...
 

I'm using merge with method = 'max' to merge two rasters with identical metadata. When I open the output file and the input files in QGIS, the top part of the output raster is perfectly merged, but the bottom part of the output raster seems to have the merged values of the pixel to it's left. Very bizarre. Has anyone experienced anything like this? Code below.


    combinedFloodList = [FluvialCropped_outputfile] + [PluvialCropped_outputfile] 
 
    # Iterate over raster files and add them to list in 'read mode'            
    allFiles = []
    for fp in combinedFloodList:
        src = rs.open(fp)
        allFiles.append(src)
 
    # Merge flood files. Using max pixel by pixel method
    floodArray, out_trans = merge(allFiles, method='max')
 
    # Save results as raster
    ## Update the metadata
    out_meta = allFiles[0].meta.copy()
    out_meta.update({"height": floodArray.shape[1], 
                      "width": floodArray.shape[2],
                      "transform": out_trans})
 
    # Output file name
    floodName = f"Flood_{countryCode}_{adm1Index}.tif"
 
    ## export as a new geotiff 
    FloodMerged_outputfile = Flood_outputFolderPath / floodName
    with rs.open(FloodMerged_outputfile, 'w', **out_meta, compress = 'LZW') as dest:
        dest.write(floodArray)


Denis Rykov
 

Do you use the latest version of rasterio?


melda.salhab.14@...
 

Yep - I'm using 1.1.0


Denis Rykov
 

The latest version is 1.1.5 (Jun 3, 2020). 1.1.0 has been released in 2019.


melda.salhab.14@...
 

Thanks for pointing that out. But it's really odd. I've been trying to update rasterio using conda, but the version remains at v1.1.0. I just tried doing a new install using conda install -c conda-forge rasterio but the version isn't changing. Any tips on how to get the latest version? I'm using a virtual environment