- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
到目前为止,我找不到更改 TIFF 文件中的 GeoTiff-TAG 的方法。我的操作系统是 Linux Lubuntu 18.04,我使用的是 Python 3.x。只是 EXIF-TAG 可以通过各种方法进行更改。
对于读取和写入 EXIF-TAG,我可以使用例如:
exiftool
exifread
PIL
tifffile
skimage.external.tifffile
特别是Python模块似乎对GeoTiff标签“视而不见”,即它们只读取(和写入)EXIF标签,而不读取GeoTiff标签。使用 exiftool,我至少可以读取并打印 GeoTiff-TAG 以及其他标签。例如,通过我的 TIFF 文件的 exiftool 的控制台输出(其中还包括 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-TAG“投影”,它会抛出以下警告消息而不更改任何内容:输入:
exiftool "-Projection=""newfile.tif"
输出:
警告:抱歉,投影不可写。无事可做。
在互联网上的搜索中,我找到了其他库和软件包,它们也许可以帮助我,但到目前为止没有用,因为我没有找到文档,或者它不起作用:
libtiff
(通过命令 tiffset ,例如 "tiffset -s Tag-Number Tag-Value dst-file"
,仅更改/添加 EXIF 标签,但不触及 GeoTIFF 标签)libgeotiff
gdal_edit
、gdal_translate
(或一般情况下的gdal
)对于后一种方法,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"
如您所见,在示例中,我尝试将名为“ProjCoordTrans”的 GeoTIFF 标签编号 3075 修改为 Costum 字符串。当执行这 4 个命令中的任何一个时,都没有抛出错误,但随后通过检查 TIFF-Tags
exiftool -D -G -a -u -U -f -s "newfile.tif"
我发现相同的TAG仍然没有变化。
我想知道是否可以更改 GeoTiff 标签。一定有这种可能。
最佳答案
我找到了一个answer在 exiftool 本身的项目页面上。此后,我将总结在页面作者Phil Harvey的帮助下我发现的内容。 .
要将所有 GeoTiff 标签从一个文件复制到另一个文件,请执行以下操作:
exiftool -tagsfromfile SRCFILE -GeoTiffDirectory -GeoTiffDoubleParams -GeoTiffAsciiParams DSTFILE
这样就可以了。我假设这些伪标签被所有子 GeoTiff 标签中的 exiftools 分割,因为 python 中的其他工具将这些伪标签打印为标签及其相关编号。能够显示这些通用 3 个 Geotiff-TAG 的 Python 包
例如:
import PIL
import tifffile as tf
from skimage.external import tifffile as sk_tf
通过我的 python 脚本使用 PILLOW (PIL) 应用于示例 TIFF 的示例输出如下:
...
** 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|',)'
...
要单独更改投影标签,您当前必须手动编辑 GeoTiffDirectory 数据。
首先将(二进制)数据写入文件:
exiftool -geotiffdirectory -b FILE.tif > out.dat
然后找到例如的偏移量投影值,例如:
exiftool FILE.tif -v3 | grep -A 2 Projection -
| 9) Projection = 16017
| - Tag 0x0c02 (2 bytes, int16u[1]):
| 0056: 3e 91 [>.]
--> 编辑 out.dat 中的字节 0x56 和 0x57 以更改为您想要的任何投影,然后将修改后的 GeoTiff 目录放回到 TIFF 文件中:
exiftool "-geotiffdirectory<=out.dat" FILE.tif
尽管如此,值得注意的是,更改 3 个关键的总结 GeoTIFF 标签,而不是尝试通过修改上述二进制文件并将其重新分配给有问题的 TIFF 来操作单个 GeoTIFF 标签之一,可能会更有效。
为了完整起见,这 3 个 GeoTIFF 标签是:
尽管如此,仅更改二进制文件中的一个特定 GeoTIFF 标签也可能会更新新 TIFF 中的 3 个关键 GeoTIFF 摘要标签。我还没试过。
如果您需要添加一些对您有用的其他信息或经验,请告诉我。
干杯
关于python - 如何更改或删除 GeoTIFF 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59428868/
我正在编写一个需要读取 4 channel geotiff 图像的代码,在本例中为 16 位图像(数据实际上是 12 位分辨率,但以 16 位编码)。 我的主要目标是读取像素值以便稍后使用它们。来自这
我正在制作一个 Python 脚本,该脚本将读取 GeoTIFF 文件,并将执行以下操作:将 GeoTIFF 转换为静态 JPEG(尺寸小得多),并创建一个单独的文本文件,其中包含 GeoTIFF h
我想在 R 中有一个 Geotiff 图像,我该怎么做?下面是一个简单的例子。我想以 Geotiff 格式生成绘图。 require(gstat) data(meuse) coordinates(me
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
我正在生成 2D 统计图,并且还想生成和保存图像颜色图。平均尺寸图像的数据类型为 float32。以下示例修改自在线资源: with rasterio.open(name,'w',**profile)
我正在尝试使用 GeoTIFF-jai 库在 Java 中生成经过地理校正的光栅图像。我尝试在 SourceForge 网站上查找有关如何执行此操作的文档,但 SourceForge 说“不幸的是,该
到目前为止,我找不到更改 TIFF 文件中的 GeoTiff-TAG 的方法。我的操作系统是 Linux Lubuntu 18.04,我使用的是 Python 3.x。只是 EXIF-TAG 可以通过
如何将 GeoTIFF(单波段)图像(例如 1000 x 1000 像素)子集化为规则的正方形网格(例如 50 x 50 像素;总共 400 个网格对象);并计算每个对象的平均纬度、平均经度和平均 D
我正在尝试使用 rasterio 加载图像,修改 ndarray,然后使用与原始图像相同的空间引用系统写出。下面的函数是我尝试这样做的。但是输出的 geotiff 中缺少空间引用系统。对我做错了什么有
如何从将 geotiff 图像分成常规 block (例如 50 x 50 像素)的图像中计算每个 block 的平均纬度和平均经度。 输入数据只是图像,例如从以下位置下载:http://eoimag
我的任务是获取一个 GeoTIFF,在其中进行一些图像分割,并将其保存到新的 GeoTIFF(具有现有坐标)。如果我理解正确,坐标将保存在 GeoTIFF 元数据中。所以我从原始文件中获取元数据: F
我有一个带有地理信息的 tif。使用 gdal,我可以将光栅文件转换为数组 (numpy)。 如何获取该数组中一个条目的坐标? 最佳答案 使用仿射变换矩阵,将像素坐标映射到世界坐标。例如,使用 aff
在Python中使用GDAL,如何获取GeoTIFF文件的经纬度? GeoTIFF 似乎不存储任何坐标信息。相反,它们存储 XY 原点坐标。但是,XY 坐标不提供左上角和左下角的经纬度。 看来我需要做
我有一个 geotiff 文件。 import xarray as xr urbanData = xr.open_rasterio('myGeotiff.tif') plt.imshow(urbanD
我有一个存储在多个 GeoTIFF 中的栅格时间序列我想转换为单个 *.tif 的文件 ( NetCDF )文件。数据是uint16 . 我可能可以使用 gdal_translate使用以下方法将每个
我有一个 PNG 图像文件。我想将其转换为 GeoTiff。我安装了 QGIS 软件,但无法使用它,也不知道如何对图像进行地理配准。请帮我。有没有在线软件? 最佳答案 这是一个非常好的教程,其中包含有
我有地理引用 tiff,gdalinfo 输出: Driver: GTiff/GeoTIFF Files: generated.tiff generated.tiff.aux.xml S
我目前有一张来自 GeoTiff 文件的 171 x 171 图像(尽管在其他情况下,我可能有更大的图像)。我的目标是获取图像中的每个像素并将其转换为纬度/经度对。 我已经能够根据这篇 StackOv
我有一组 png 文件和每个文件边缘的 EPSG:3006 坐标。如何使用 Python 将这些 png 文件转换为 geotiff 文件,以便 tiff 文件包含地理元数据。 我想这可以用 Rast
我有一组 png 文件和每个文件边缘的 EPSG:3006 坐标。如何使用 Python 将这些 png 文件转换为 geotiff 文件,以便 tiff 文件包含地理元数据。 我想这可以用 Rast
我是一名优秀的程序员,十分优秀!