I have some Python GDAL code I am using to convert a GeoTIFF file to PNG. The code uses the
gdal.Translate() function which generates a new file each time I run it. However, I was wondering if there is a way to get the Python
gdal.Translate() function to return a python object instead of writing a file? Ideally I would like to write to a
numpy array or something, but any kind of internal object would be fine.
Here is some sample code I am using:
from osgeo import gdal scale = '-scale min_val max_val' options_list = [ '-ot Byte', '-of JPEG', scale ] options_string = " ".join(options_list) gdal.Translate('test.jpg', 'test.tif', options=options_string)
I looked over the documentation and source code to figure out how
gdal.Translate() worked, but could not get past the
TranslateInternal() function. I could not find a link through the source code past that.