0 votes
in Python Imaging Library by
How to Watermarking TIFF with pillow in Python breaks georeferencing

1 Answer

0 votes
by
use gdal/ogr to georeference your output rasters using the metadata from the input rasters.

from osgeo import gdal, ogr

src_tif = gdal.Open('input.tif')

new_tif = gdal.Open('output.tif')

ulx, xres, xskew, uly, yskew, yres  = src_tif.GetGeoTransform()

lrx = ulx + (src_tif.RasterXSize * xres)

lry = uly + (src_tif.RasterYSize * yres)

gdal.Translate('georeferenced_input.tif', new_tif, outputBounds=[ulx,uly,lrx,lry])

Related questions

0 votes
asked Oct 1, 2023 in Python Imaging Library by sharadyadav1986
0 votes
asked May 3, 2022 in Cyber Security by sharadyadav1986
...