Create raster aligned with one created by gdal_translate
Denis Rykov
Hi everyone! I tried to convert
Eventually I came up with the following solution that produces raster aligned with one produced by
It works fine but I still have couple of questions:
Any advice would be appreciated. |
|
I had a very similar approach to calculate the new affine & width/height manually as you. But I have now replaced it with just rasterio functions and when comparing the results of the new affine, they were identical :-)
I just wonder, why you add 0.5 when calculating the height & width? My code looked like this (windows is the extent I am matching my raster to, profile is the target raster profile, copied from my source raster and then modified)
But i have replaced all this now by:
Both methods actually created and affine with the same values, that is why I replaced my own code with the rasterio functions. |
|
Denis Rykov
Thanks Thomas. I've tried your approach but it still gives me a shifted output compared to gdal_translate. |
|
thomaswanderer@...
I also still fight with the shifted by one pixel problem for 1 extent out of 5 extents. 4 return perfectly aligned clipped subsets of the source raster, 1 does not. |
|
Denis Rykov
The issue has been fixed via https://github.com/mapbox/rasterio/commit/15d8dd759256f12d412433f5b9824c8d16b33f8d. |
|