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?
You can use programming languages or windows software. If you want just to view nc file and display it, Panoply is the best and you can use free version of Netcdf Extractor for viewing. But, if you want to extract time series from one file or many files, you can use Netcdf Extractor and do it easily.
Click Tools. Click Make NetCDF Raster Layer in the returned list to open the tool. Type the name in the Input netCDF File text box, or click the browse button to navigate to the input file. Click the Variable drop-down arrow and choose a variable from the list.
Start ArcMap. Select the tool "Make NetCDF Raster Layer" by either using the "Search" or expanding the branch "Multidimension Tools" in the "ArcToolbox". For the input field "Input netCDF File" select the NetCDF file downloaded in step 1. Click the Variable drop-down arrow and choose a variable from the list.
There are different ways to open a netCDF file in QGIS. Either click on the icon on the top left, as shown below, or drag and drop a file directly onto the map canvas. Choose a netCDF file (. nc), then click on the variable you want; for example, temperature.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With