【问题标题】:How to read location coordinates of MODIS HDF file with Python GDAL?如何使用 Python GDAL 读取 MODIS HDF 文件的位置坐标?
【发布时间】:2022-11-12 14:25:48
【问题描述】:

我正在尝试使用 Python 读取 MODIS HDF 文件。我使用过 GDAL 和 pyhdf 库。但是,我不确定为什么 GDAL 无法读取位置坐标,而 pyhdf 可以轻松读取相同的位置。 以下是简单的python代码。

from pyhdf import SD
from osgeo import gdal

filename = 'MYD04_3K.A2016001.0310.061.2018059005952.hdf'

gdal_ds= gdal.Open(filename)
hdf_ds = SD.SD(filename)
print (hdf_ds.datasets())

for path, desc in file.GetSubDatasets():
    print(desc)

pyhdf 的输出如下:

{'Longitude': (('Cell_Along_Swath:mod04', 'Cell_Across_Swath:mod04'), (676, 451), 5, 0), 'Latitude': (('Cell_Along_Swath:mod04', 'Cell_Across_Swath:mod04'), (676, 451), 5, 1), 'Scan_Start_Time': (('Cell_Along_Swath:mod04', 'Cell_Across_Swath:mod04'), (676, 451), 6, 2), 'Solar_Zenith': (('Cell_Along_Swath:mod04', 'Cell_Across_Swath:mod04'),

GDAL 的输出如下:

[676x451] Solar_Zenith mod04 (16-bit integer)
[676x451] Solar_Azimuth mod04 (16-bit integer)

我想了解为什么 GDAL 无法在此处读取位置坐标。有什么我想念的吗?如何使用 GDAL 库提取位置信息?我的主要目标最终是在地图上绘制 HDF 文件中的特定变量。

【问题讨论】:

  • 这是一条,所以仍然是一个不规则的网格(没有任何投影)。元数据中有连接点(GCP),因此您可以使用带有gdalwarp 的连接点将其转换为常规网格。但这些可能精度较低,使用匹配的地理位置文件(例如 MYD03* 之类的(?),它应该包含纬度/经度数组以及每个像素的坐标,您将获得更好的结果。

标签: python hdf5 gdal pyhdf


【解决方案1】:

检查从 1952 年到 1954 年的线路

https://github.com/OSGeo/gdal/blob/master/frmts/hdf4/hdf4imagedataset.cpp

pyhdf 不查找纬度/经度数据集。它是 HDF4 库的简单包装器。

【讨论】:

    猜你喜欢
    • 2013-01-05
    • 1970-01-01
    • 2014-05-07
    • 2021-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-05
    • 1970-01-01
    相关资源
    最近更新 更多