到目前为止,我找不到一种方法来更改TIFF文件中的GeoTiff标记。 我的操作系统是LinuxLubuntu18.04,我使用的是Python3.x。 只有EXIF标签可以通过各种方法进行更改。你知道吗
对于读取和写入EXIF标记,我可以使用例如:
尤其是python模块似乎对GeoTiff标记“视而不见”,即它们只读取(和写入)EXIF标记,而不读取GeoTiff标记。 使用exiftool,我至少可以读取和打印GeoTiff标签以及其他标签。 例如,通过exiftool对我的TIFF文件(也包括GeoTiff标记)的控制台输出是:
输入:
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标记“Projection”,它在不更改任何内容的情况下抛出以下警告消息: 输入:
exiftool "-Projection=" "newfile.tif"
输出:
Warning: Sorry, Projection is not writable. Nothing to do.
在我的互联网搜索中,我发现了其他的库和包,它们也许可以帮助我,但到目前为止没有任何帮助,因为我没有找到文档,或者它不起作用:
至于后一种方法gdal_edit和gdal_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"
如您所见,在该示例中,我尝试将GeoTIFF标签号3075(名为“ProjCoordTrans”)修改为costum字符串。当执行这4个命令中的任何一个时,没有抛出任何错误,但随后通过检查TIFF标记
exiftool -D -G -a -u -U -f -s "newfile.tif"
我发现同样的标签仍然没有改变。你知道吗
我想知道是否有可能改变GeoTiff标签。一定有可能。你知道吗
我在exiftool本身的项目页面上发现了一个answer。 此后,我将在页面作者Phil Harvey的帮助下总结我发现的内容。你知道吗
要将所有GeoTiff标记从一个文件复制到另一个文件,请执行以下操作:
这就成功了。 我假设这些伪标记是由exiftools在所有子GeoTiff标记中分割的,因为python中的其他工具将这些伪标记及其相关编号打印出来。 Python包,能够显示这些通用的3个Geotiff标记
例如:
通过应用于示例TIFF的python脚本使用枕头(PIL)的示例输出如下:
要单独更改投影标记,当前必须手动编辑GeoTiffDirectory数据。你知道吗
首先将(二进制)数据写入文件:
然后找到偏移量,例如投影值,如:
>;编辑中的字节0x56和0x57输出.dat要更改为所需的任何投影,请将修改后的GeoTiff目录放回TIFF文件中:
然而,需要注意的是,更改3个GeoTIFF标记,而不是试图通过修改上述二进制文件并将其重新分配给所讨论的TIFF来操作单个GeoTIFF标记中的一个,可能更有效。你知道吗
为了完成,这3个GeoTIFF标签是:
尽管如此,只要在二进制文件中更改一个特定的GeoTIFF标记,就有可能更新新TIFF中3个关键的GeoTIFF摘要标记。 我还没试过呢。你知道吗
如果您必须添加一些额外的信息或经验,这些方法,为您工作等,让我知道。你知道吗
干杯
相关问题 更多 >
编程相关推荐