将 NetCDF (.nc) 转换为 GEOTIFF

Convert NetCDF (.nc) to GEOTIFF

我有 .nc 个大小约为 300MB 的文件,其中包含几个数据集(TEMPDEWPOINT)预测数据。我需要将 (TEMP) 数据集转换为多个 GEOTIFF(每个时间片一个 .tif)。

这是 .nc 文件的样子。

调查了这个 answer 但它似乎适用于整个数据集。

我尝试了 GDAL 但不确定如何让它适用于每个时间片。

有什么想法吗? netcdf4-python?

gdal 有一个 gdal_translate 选项,允许您将文件从 .nc 转换为 .tiff

见下文:

gdal_translate -of GTiff file.nc test.tiff

并且使用 -b 选项将允许您指定要转换的波段。

gdal_translate -of GTiff -b 10 file.nc test.tiff  # to get 10th band

来自docs

-b band: Select an input band band for output. Bands are numbered from 1. Multiple -b switches may be used to select a set of input bands to write to the output file, or to reorder bands. Starting with GDAL 1.8.0, band can also be set to "mask,1" (or just "mask") to mean the mask band of the first band of the input dataset.

不幸的是,你必须知道你想要哪个波段(以数字形式而不是 date/time 形式),但是一个简单的脚本可以用来迭代时间维度并获得你需要的索引或者简单地逐一遍历每个波段。