我如何更改或删除GeoTIFF标签?

问题描述 投票:1回答:1

到目前为止,我找不到在TIFF文件中更改GeoTiff-TAG的方法。我的操作系统是Linux Lubuntu 18.04,我使用的是Python3.x。只是EXIF-TAG可以通过各种方法进行更改。

对于读写EXIF标签,我可以使用例如:

  • 命令行工具:exiftool
  • python-module:exifread
  • python-module:PIL
  • python-module:tifffile
  • python-module:skimage.external.tifffile

尤其是python模块似乎对GeoTiff-Tag视而不见,即它们仅读取(和写入)EXIF-TAG,而不能读取(或写入)EXIF-TAG。使用exiftool,我至少可以读取和打印GeoTiff-TAG以及其他标签。例如,通过我的TIFF文件的exiftool进行的控制台输出,其中还包括GeoTiff-Tag,将是:

输入:

exiftool -D -G -a -u -U -f "newfile.tif"

输出:

[ExifTool]          - ExifTool Version Number         : 10.80
[File]              - File Name                       : newfile.tif
[File]              - Directory                       : .
[File]              - File Size                       : 1503 kB
[File]              - File Modification Date/Time     : 2019:12:19 17:32:17+01:00
[File]              - File Access Date/Time           : 2019:12:19 17:32:17+01:00
[File]              - File Inode Change Date/Time     : 2019:12:19 17:32:17+01:00
[File]              - File Permissions                : rw-rw-r--
[File]              - File Type                       : TIFF
[File]              - File Type Extension             : tif
[File]              - MIME Type                       : image/tiff
[File]              - Exif Byte Order                 : Little-endian (Intel, II)
[File]              - Current IPTC Digest             : 79ffcf282ca6974ff99640a7421b40b7
[EXIF]            256 Image Width                     : 1148
[EXIF]            257 Image Height                    : 1337
[EXIF]            258 Bits Per Sample                 : 8
[EXIF]            259 Compression                     : Uncompressed
[EXIF]            262 Photometric Interpretation      : RGB Palette
[EXIF]            273 Strip Offsets                   : (Binary data 1390 bytes, use -b option to extract)
[EXIF]            274 Orientation                     : Horizontal (normal)
[EXIF]            277 Samples Per Pixel               : 1
[EXIF]            278 Rows Per Strip                  : 7
[EXIF]            279 Strip Byte Counts               : (Binary data 954 bytes, use -b option to extract)
[EXIF]            282 X Resolution                    : 1
[EXIF]            283 Y Resolution                    : 1
[EXIF]            284 Planar Configuration            : Chunky
[EXIF]            296 Resolution Unit                 : None
[EXIF]            305 Software                        : IMAGINE TIFF Support.Copyright 1991 - 1999 by ERDAS, Inc. All Rights Reserved.@(#)$RCSfile: etif.c $ $Revision: 1.11 $ $Date$
[EXIF]            320 Color Map                       : (Binary data 1536 bytes, use -b option to extract)
[EXIF]            339 Sample Format                   : Unsigned
[EXIF]          33550 Pixel Scale                     : 30 30 0
[EXIF]          33922 Model Tie Point                 : 0 0 0 1514925 1583985 0
[IPTC]             25 Keywords                        : word
[IPTC]              0 Application Record Version      : 4
[GeoTiff]           1 Geo Tiff Version                : 1.1.0
[GeoTiff]        1024 GT Model Type                   : Projected
[GeoTiff]        1025 GT Raster Type                  : Pixel Is Area
[GeoTiff]        1026 GT Citation                     : IMAGINE GeoTIFF Support.Copyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved.@(#)$RCSfile: egtf.c $ $Revision: 1.11.2.3 $ $Date: 2004/11/24 09:12:56EST $.Projection Name = USA_Contiguous_Albers_Equal_Area_Conic_USGS_version.Units = meters.GeoTIFF Units = meters
[GeoTiff]        2048 Geographic Type                 : NAD83
[GeoTiff]        3072 Projected CS Type               : User Defined
[GeoTiff]        3073 PCS Citation                    : IMAGINE GeoTIFF Support.Copyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved.@(#)$RCSfile: egtf.c $ $Revision: 1.11.2.3 $ $Date: 2004/11/24 09:12:56EST $.Projection = Albers Conical Equal Area
[GeoTiff]        3074 Projection                      : User Defined
[GeoTiff]        3075 Proj Coord Trans                : Albers Equal Area
[GeoTiff]        3076 Proj Linear Units               : Linear Meter
[GeoTiff]        3078 Proj Std Parallel 1             : 29.5
[GeoTiff]        3079 Proj Std Parallel 2             : 45.5
[GeoTiff]        3081 Proj Nat Origin Lat             : 23
[GeoTiff]        3082 Proj False Easting              : 0
[GeoTiff]        3083 Proj False Northing             : 0
[GeoTiff]        3088 Proj Center Long                : -96
[Composite]         - Image Size                      : 1148x1337
[Composite]         - Megapixels                      : 1.5

然后,我尝试更改/删除例如GeoTiff-TAG“投影”,它会在不进行任何更改的情况下引发以下警告消息:输入:

exiftool "-Projection=" "newfile.tif"

输出:

Warning: Sorry, Projection is not writable. Nothing to do.

在互联网上搜索时,我发现了其他库和程序包,它们也许可以帮到我,但是到目前为止没有用,因为我没有找到文档,或者它没有用:

  • libtiff(通过命令tiffset,例如“ tiffset -s标记号标记值dst文件”,它仅更改/添加EXIF标记,但不接触GeoTIFF标记)
  • libgeotiff
  • gdal_edit,gdal_translate(或一般说来,是gdal)

至于后一种方法gdal_editgdal_translate,我尝试了以下操作,但没有任何效果(即使没有任何错误消息):

gdal_edit.py -mo "3075=Custom" "newfile.tif"
gdal_edit.py -mo "ProjCoordTrans=Custom" "newfile.tif"
gdal_translate -mo "3075=Custom" "newfile.tif" "newfile_2.tif"
gdal_translate -mo "ProjCoordTrans=Custom" "newfile.tif" "newfile_2.tif"

如您所见,在示例中,我尝试将名为“ ProjCoordTrans”的GeoTIFF-Tag号3075修改为Costum字符串。当执行这4个命令中的任何一个时,都不会引发任何错误,而是通过[]之后检查TIFF-Tags

exiftool -D -G -a -u -U -f -s "newfile.tif"

我发现相同的TAG仍然保持不变。

我想知道是否有可能更改GeoTiff标签。一定有可能。

到目前为止,我找不到在TIFF文件中更改GeoTiff-TAG的方法。我的操作系统是Linux Lubuntu 18.04,我使用的是Python3.x。只是EXIF-TAG可以通过各种方法进行更改。对于两个...

python geotiff
1个回答
0
投票

我在exiftool本身的项目页面上找到了answer。此后,我将总结在页面作者Phil Harvey的帮助下发现的内容。

© www.soinside.com 2019 - 2024. All rights reserved.