nc转tif python_将NetCDF(.nc)转换为GEOTIFF

该博客介绍了如何使用GDAL的gdal_translate工具将300MB大小的NC文件中TEMP数据集按时间切片转换为多个GEOTIFF格式,特别针对每个时间点单独操作的方法和步骤。提到需要指定输入带号,但未提及具体脚本实现细节。
摘要由CSDN通过智能技术生成

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

Here is how the .nc file looks like.

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

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

Any thoughts? netcdf4-python?

解决方案

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

See below:

gdal_translate -of GTiff file.nc test.tiff

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

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

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值