I've found an answer on the project-page of exiftool itself.
Hereafter, I'll summarize what I found out with the kind help of the page-author Phil Harvey.
To copy all GeoTiff tags from one file to another, do this:
exiftool -tagsfromfile SRCFILE -GeoTiffDirectory -GeoTiffDoubleParams -GeoTiffAsciiParams DSTFILE
That does the trick.
I assume that those pseudo-TAGs are split-up by exiftools in all sub-GeoTiff-TAGs, because other tools in python print these out as TAGs with their associated numbers.
Python packages which are able to display these general 3 Geotiff-TAGs
- ('34735') 'GeoKeyDirectoryTag'
- ('34736') 'GeoDoubleParamsTag'
- ('34737') 'GeoAsciiParamsTag'
are for example:
import PIL
import tifffile as tf
from skimage.external import tifffile as sk_tf
An example output using PILLOW (PIL) via my python script applied on an example TIFF would be:
...
** GENERIC APPROACH USING PILLOW-package **
TAG number: '254'
TAG name: 'NewSubfileType'
TAG value: '(0,)'
TAG number: '256'
TAG name: 'ImageWidth'
TAG value: '(2388,)'
TAG number: '257'
TAG name: 'ImageLength'
TAG value: '(1651,)'
TAG number: '258'
TAG name: 'BitsPerSample'
TAG value: '(8,)'
TAG number: '259'
TAG name: 'Compression'
TAG value: '(1,)'
TAG number: '262'
TAG name: 'PhotometricInterpretation'
TAG value: '(1,)'
TAG number: '270'
TAG name: 'ImageDescription'
TAG value: '('{"shape": [1651, 2388]}',)'
TAG number: '274'
TAG name: 'Orientation'
TAG value: '(1,)'
TAG number: '277'
TAG name: 'SamplesPerPixel'
TAG value: '(1,)'
TAG number: '278'
TAG name: 'RowsPerStrip'
TAG value: '(1651,)'
TAG number: '282'
TAG name: 'XResolution'
TAG value: '((1, 1),)'
TAG number: '283'
TAG name: 'YResolution'
TAG value: '((1, 1),)'
TAG number: '284'
TAG name: 'PlanarConfiguration'
TAG value: '(1,)'
TAG number: '296'
TAG name: 'ResolutionUnit'
TAG value: '(1,)'
TAG number: '305'
TAG name: 'Software'
TAG value: '('tifffile.py',)'
TAG number: '339'
TAG name: 'SampleFormat'
TAG value: '(1,)'
TAG number: '33550'
TAG name: 'ModelPixelScaleTag'
TAG value: '(30.0, 30.0, 0.0)'
TAG number: '33922'
TAG name: 'ModelTiepointTag'
TAG value: '(0.0, 0.0, 0.0, 737125.0, 4328658.0, 0.0)'
TAG number: '34735'
TAG name: 'GeoKeyDirectoryTag'
TAG value: '(1, 1, 0, 15, 1024, 0, 1, 1, 1025, 0, 1, 1, 1026, 34737, 266, 0, 2048, 0, 1, 4269, 3072, 0, 1, 32767, 3073, 34737, 197, 266, 3074, 0, 1, 32767, 3075, 0, 1, 11, 3076, 0, 1, 9001, 3078, 34736, 1, 0, 3079, 34736, 1, 1, 3081, 34736, 1, 2, 3082, 34736, 1, 3, 3083, 34736, 1, 4, 3088, 34736, 1, 5)'
TAG number: '34736'
TAG name: 'GeoDoubleParamsTag'
TAG value: '(29.5, 45.5, 23.0, 0.0, 0.0, -96.0)'
TAG number: '34737'
TAG name: 'GeoAsciiParamsTag'
TAG value: '('IMAGINE GeoTIFF Support\nCopyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile: egtf.c $ $Revision: 1.11.2.3 $ $Date: 2004/11/24 09:12:56EST $\nProjection Name = USA_Contiguous_Albers_Equal_Area_Conic_USGS_version\nUnits = meters\nGeoTIFF Units = meters|IMAGINE GeoTIFF Support\nCopyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile: egtf.c $ $Revision: 1.11.2.3 $ $Date: 2004/11/24 09:12:56EST $\nProjection = Albers Conical Equal Area|',)'
...
To change the Projection tag alone, you would currently have to manually edit the GeoTiffDirectory data.
First write the (binary) data to a file:
exiftool -geotiffdirectory -b FILE.tif > out.dat
Then find the offset of e.g. the Projection value, like:
exiftool FILE.tif -v3 | grep -A 2 Projection -
| 9) Projection = 16017
| - Tag 0x0c02 (2 bytes, int16u[1]):
| 0056: 3e 91 [>.]
--> Edit bytes 0x56 and 0x57 in out.dat to change to whatever projection you want, then put the modified GeoTiff directory back into the TIFF file:
exiftool "-geotiffdirectory<=out.dat" FILE.tif
Nevertheless, it is important to note, that changing the 3 crucial summarizing GeoTIFF-Tags, instead of trying to manipulate one of the single GeoTIFF-TAGs via modifying the above-mentioned binary-file and reassign it to the TIFF in question, could be more effective.
For the sake of completion, these 3 GeoTIFF-Tags were:
- ('34735') 'GeoKeyDirectoryTag'
- ('34736') 'GeoDoubleParamsTag'
- ('34737') 'GeoAsciiParamsTag'
Nevertheless, it could be possible that by changing just one specific GeoTIFF-Tag within the binary-file is also going to update as a result the 3 crucial GeoTIFF-summary-Tags in new TIFF.
I haven't tried that out yet.
If you have to add some additional information or experiences with these approaches, which work for you etc., let me know.
Cheers
Best Answer
Rasterio would be an easy choice to get the information you need via Python. This code gets the bounding geometry of a geotiff.