Convert NetCDF (.nc) to GEOTIFF

霸气de小男生 提交于 2019-12-20 01:05:52

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/52046282/convert-netcdf-nc-to-geotiff

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!