I have two files, GeoTIFFs (.tif) in this case which need to be cropped to each other's minimum overlap, and have matching spatial resolutions. I also want to round their Pixel Size to a whole number (50m in my case). I strongly prefer using gdal or a similiar alternative like rasterio.
Upper left (240650.486, 4234958.562) Pixel Size (50.000101..., -50.000101...)
Lower Left (242715.000, 4234848.000) Pixel Size (50.00023..., -50.00023...)
Say I found the min overlapping extent in python for instance:
left_bounds = max(min(xcoords1), min(xcoords2)) right_bounds = min(max(xcoords1), max(xcoords2)) #same for lower_bounds and upper_bounds
I still couldn't simply
gdalwarp -te left_bounds lower_bounds right_bounds top_bounds because my resolution still needs rounding.
Essentially I would like to do all this through gdal commands, but am curious the most parsimonious string of gdal commands that could clip to bounds, ensure alignment of two tifs, and round resolution to 50m
AND! If possible, find the lower_bounds, upper_bounds, etc. without resorting to an external scripts or parsing gdalinfo outputs in the command line.