I wish to convert this Python code using a gdal command line tool to using the gdal python library. I am using it to convert some PNG satellite images I am downloading to georeferenced TIFFs. I manually specify the bounding box of the images when I download them (in EPSG:3857), so I know all the info about the images, I just wish to store all the info in a single georeferenced TIFF file.
My current solution is to use gdal_translate
called by subprocess
but apparently this can all be done natively in python, so I would prefer to do that rather than rely on this hacked-together workaround.
from osgeo import gdal
import subprocess
import shlex
# ll_x etc... are all corner coords I calculate before hand
subprocess.run(shlex.split("gdal_translate -of GTiff -a_ullr {} {} {} {} -a_srs {} {} {}".format(
ll_x, ur_y, ur_x, ll_y,
"EPSG:3857",
"input_sat_image.png",
"referenced_sat.tif")))
I have seen individual questions that cover pieces of this, but I am struggling to put them all together.