Topics

Reprojecting output image to input image crs where the image sizes differ

ashnair0007@...
 

I have a geotiff (size= 4490 x 7341) that I cut into 256 x 256 crops to do an operation. Once the operation is done, I merge them back together. Since the original dimensions aren't divisible by 256 the resulting image will be of size 4608 x 7424. However the output tif and the input tif are of the same location, so they need to be geo-referenced the same. Is it possible to do so?

Sean Gillies
 

Hi,

On Tue, Jul 21, 2020 at 11:52 PM <ashnair0007@...> wrote:
I have a geotiff (size= 4490 x 7341) that I cut into 256 x 256 crops to do an operation. Once the operation is done, I merge them back together. Since the original dimensions aren't divisible by 256 the resulting image will be of size 4608 x 7424. However the output tif and the input tif are of the same location, so they need to be geo-referenced the same. Is it possible to do so?

If your original raster's georeferencing did not involve rotation, and if the merged raster has the same origin (upper left corner) as the original, you can reuse the original raster's transform property. If the merged raster has a different origin, you must compute a new transform using https://rasterio.readthedocs.io/en/latest/api/rasterio.transform.html#rasterio.transform.from_bounds or https://rasterio.readthedocs.io/en/latest/api/rasterio.transform.html#rasterio.transform.from_origin.

Sorry about the late reply. I hope it is still useful.

--
Sean Gillies