2

I want to convert monthly precipitation netCDF file, downloaded from TerraClimate data to GeoTIFF and available as 1 file per year. Example: http://thredds.northwestknowledge.net:8080/thredds/fileServer/TERRACLIMATE_ALL/data/TerraClimate_ppt_2020.nc (+-103MB).

To do the conversion for each month, I use CDO to select the date. Below is the complete script:

for t in `cdo showdate TerraClimate_ppt_2020.nc`; do
   cdo seldate,$t TerraClimate_ppt_2020.nc dummy.nc
   gdal_translate -of GTiff -a_ullr -180 90 180 -90 -a_srs EPSG:4326 dummy.nc ../tif/TerraClimate_ppt_$t.tif
done

Unfortunately the result when I open to QGIS is upside down. Is there any configuration options from CDO or GDAL that I should use in above script to avoid the upside down result?

Below is the metadata from ncdump and gdalinfo, also result in qgis.

gdalinfo

ncdump

qgis

2
  • I think gdalmdimtranslate (gdal.org/programs/gdalmdimtranslate.html) is a perfect use case for your problem. Oct 24 at 7:23
  • 1
    I was not aware if gdal has gdalmdimtranslate. I just tried your suggestion gdalmdimtranslate -of GTiff -co COMPRESS=LZW -co PREDICTOR=1 dummy.nc ../TerraClimate_ppt_$t.tif and it's worked. Thank you and could you post your suggestion as answer instead of comment, so I can accept it.
    – user97103
    Oct 24 at 7:35
2

I think gdalmdimtranslate is a perfect use case for your problem (New in version 3.1).

Reposting what worked for you

gdalmdimtranslate -of GTiff -co COMPRESS=LZW -co PREDICTOR=1 dummy.nc ../TerraClimate_ppt_$t.tif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.