converting netcdf file to tiff file using gdal_translate

1,569 views
Skip to first unread message

Theo Awo

unread,
Nov 8, 2017, 6:54:18 PM11/8/17
to RSGISLib Support
Hi All,

I have a netcdf file of about 4.4GB in size (I guess the file isn't too big for conversion?) and have used gdal_translate to convert to tiff, using the following

gdal_translate -of GTiff lake.nc lake.tif

but got an error:

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Input file contains subdatasets. Please, select one of them for reading.

Is there a way I can get the whole file as a multiband tiff or at least the three bands I need and am I using the right extension (nc)?

Also, I want the spatial referencing information (long/lat) in my output. 

Peter Bunting

unread,
Nov 9, 2017, 11:10:09 AM11/9/17
to Theo Awo, RSGISLib Support
Hi Theo,

Probably one for the gdal mailing list. However, like HDF5 files netcdf has different subdatasets so you need so specify which one you want. For example:

gdal_translate -of GTIFF NETCDF:"RainDays1_1961-1990_LTA_25km.nc":raindays_tmean_abs output_RD.tif

If you do gdalinfo you will get a list of subdatasets, you will need to convert them independently.

Best wishes,

Pete

****************************************************
* Dr Pete Bunting
* Reader in Remote Sensing
* Earth Observation and Ecosystem Dynamics Group
* Department of Geography and Earth Sciences
* Aberystwyth University
* Aberystwyth
* Ceredigion
* SY23 3DB
* UK
*
* Ph: +44 (0) 1970 622615
* Mob: +44 (0) 7917 842743
* Email: p...@aber.ac.uk
* ORCID: http://orcid.org/0000-0002-7435-0148
****************************************************
"Please consider the environment before printing this email or any documents attached”
> --
> You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
> To post to this group, send email to rsgislib...@googlegroups.com.
> Visit this group at https://groups.google.com/group/rsgislib-support.
> For more options, visit https://groups.google.com/d/optout.

Theo Awo

unread,
Nov 9, 2017, 2:01:27 PM11/9/17
to Peter Bunting, RSGISLib Support
Thanks Pete! It works but long/lat info are lost in the output. Oh, I'll visit the gdal mailing list for more info on that.

Regards.

> To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-support+unsubscribe@googlegroups.com.
> To post to this group, send email to rsgislib-support@googlegroups.com.

Peter Bunting

unread,
Nov 10, 2017, 3:21:07 AM11/10/17
to Theo Awo, RSGISLib Support
Hi Theo,

If it is just a one of image then you could look up the projection info using gdalinfo and then use the following rsgislib functions to define the projection information:

rsgislib.imageutils.assignProj(inputImage, wktString, wktFile)
http://www.rsgislib.org/rsgislib_imageutils.html#rsgislib.imageutils.assignProj

rsgislib.imageutils.assignSpatialInfo(inputImage, tlX, tlY, resX, resY, rotX, rotY)
http://www.rsgislib.org/rsgislib_imageutils.html#rsgislib.imageutils.assignSpatialInfo

Best wishes,

Pete
> > To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
> > To post to this group, send email to rsgislib...@googlegroups.com.

Theo Awo

unread,
Nov 12, 2017, 3:22:17 AM11/12/17
to Peter Bunting, RSGISLib Support
Thanks Pete!

> > To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-support+unsubscribe@googlegroups.com.
> > To post to this group, send email to rsgislib-support@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages