I am making a Python script which will read in a GeoTIFF file, and will do both: convert the GeoTIFF into a static JPEG (that is much smaller in size), and create a separate text file which contains the GeoTIFF headers.
Using the Python GDAL API, I am able to get the script to open a GeoTIFF file, and print details, such as the RasterXSize, RasterYSize, RasterCount, etc.
The problem is with saving a JPEG. I have researched the driver.CreateCopy() method, however, all it does is create a very large JPEG file that is blank and can’t be opened.
Also, which method retrieves all of the GeoTIFF Headers that I can save to a file?
I’m neither an expert on GeoTIFFs nor GDAL, and I greatly appreciate the assistance!
I figured it out myself with some Googling.
To save the .jpg file with varying level of quality, you need to use the following code:
The parameters I need are stored in both the
theDataset.GetGeoTransform(), and thetheDataset.GetProjection()methods.Special thanks to this site: http://adventuresindevelopment.blogspot.com/2008/12/python-gdal-set-jpeg-quality-values-and.html