【发布时间】: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* 之类的(?),它应该包含纬度/经度数组以及每个像素的坐标,您将获得更好的结果。