将NetCDF(.nc)转换为GEOTIFF [英] Convert NetCDF (.nc) to GEOTIFF

查看:1284
本文介绍了将NetCDF(.nc)转换为GEOTIFF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have .nc file sizing around 300MB with a couple of datasets (TEMP, DEWPOINT) forecast data. I need to convert (TEMP) dataset to multiple GEOTIFF (one .tif for each time slice).

这是.nc文件的外观.

已查看此 answer ,但似乎用于整个数据集.

Looked into this answer but it seems to be for the whole dataset.

我尝试了GDAL,但不确定如何在每个时间片中使用它.

I tried GDAL but not sure how to make it work for each time slice.

有什么想法吗? netcdf4 -python?

Any thoughts? netcdf4-python?

推荐答案

gdal具有gdal_translate选项,通过该选项,您可以将文件从.nc转换为.tiff.

gdal has a gdal_translate option that will allow you to do this to translate the file from .nc to .tiff.

参见下文:

gdal_translate -of GTiff file.nc test.tiff

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

and using the -b option will allow you to specify which band you want to convert.

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

来自文档:

-b频段:选择一个输入频段进行输出.波段从1开始编号.可以使用多个-b开关来选择一组输入波段以写入输出文件或对波段进行重新排序.从GDAL开始 1.8.0,band也可以设置为"mask,1"(或简称为"mask"),表示输入数据集第一个波段的遮罩波段.

-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.

不幸的是,您将必须知道想要的波段(以数字形式而不是日期/时间形式),但是可以使用一个简单的脚本在时间维度上进行迭代并获取所需的索引,或者简单地遍历每个乐队一对一.

Unfortunately, you will have to know which band you want (in numerical form as opposed it's date/time form), but a simple script can be used to iterate over the time dimension and obtain the index you need or simply iterate through each band one-by-one.

这篇关于将NetCDF(.nc)转换为GEOTIFF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆