如何获取geotiff堆栈中的乐队名称?
从像 'NDVI_TS.tif'
这样的文件中的 geotiff(NDVI 时间序列)堆栈中,我想获取单独的波段名称。例如:“频段 086:20190803T004719”
。例如,当我将堆栈加载到 QGIS 中时,我可以看到这一点。我需要追溯名称中的日期,在上面的示例中为 2019-08-03
。但是,我找不到从 Python 访问它的方法。我可以通过索引访问这些乐队,但这并不能帮助我找到它们来自哪个日期。
from osgeo import gdal
NDVI = gdal.Open('NDVI_TS.tif', gdal.GA_ReadOnly)
#for example I can get data from band 86 as and array with:
band86 = NDVI.GetRasterBand(86).ReadAsArray()
我觉得应该有一些简单的解决方案,但未能找到。
From an stack of geotiff (time-series of NDVI) in a file like 'NDVI_TS.tif'
I want to get individual band names. For example: 'Band 086: 20190803T004719'
. I can see that when I load the stack into QGIS for example. I need to trace back the dates in the name, in the example above would be 2019-08-03
. However, I can't find a way to access it from Python. I can access the bands by index but that doesn't help me finding from which date they are from.
from osgeo import gdal
NDVI = gdal.Open('NDVI_TS.tif', gdal.GA_ReadOnly)
#for example I can get data from band 86 as and array with:
band86 = NDVI.GetRasterBand(86).ReadAsArray()
I feel there should be some easy solution for this but failed to find.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道这是否有效,但这是我解决这个问题的方法(仅用小图像进行测试):
您会得到一本带有乐队名称(您在 QGIS 中看到的)及其各自索引的字典。
您可以创建一个小函数来解析乐队名称并根据需要获取日期(没有正确测试):
然后您可以应用到之前的字典:
希望它有帮助
I don't know if this is efficient, but is the way I solve this (only tested with small images):
You get a dictionary with the band name (the one you see in QGIS) and their respective index.
You can create a small function to parse the band name and get the dates as you want (didn't test it properly):
And then you can apply to the previous dict:
Hope it helps