How do I convert a GeoTIFF into a NetCDF file?

We recommend using the Geospatial Data Abstraction Library (GDAL) to convert GeoTIFF files into a different format.

If you want to reproject to lat/lon as well, then we recommend reprojecting before converting to NetCDF (see the help article "How do I reproject a GeoTIFF to from polar steroegraphic to geographic lat/lon?"). Here, we outline command line and python options for using GDAL to convert GeoTIFF files into NetCDF format.

GDAL in the command line

  1. You will need to have GDAL already installed. If you need to install it, then further details can be found at https://gdal.org.
  2. Open a terminal/command prompt and navigate to the folder where the file that you want to convert is.
  3. Run the following command in the command line:

    gdal_translate -of NetCDF <input filename> <output filename>

    For example, if you wanted to convert 'Greenland_vel_moasic_250_vy_v1.tif to a netCDF file:
     

    gdal_translate -of NetCDF Greenland_vel_mosaic_250_vy_v1.tif Greenland_vel_mosaic_250_vy_v1.nc

GDAL in python

  1. You will need the GDAL package installed in your python environment.
  2. The following code can be used to convert a geoTIFF to a netCDF file:
     

    from osgeo import gdal
    #Change the following variables to the file you want to convert (inputfile) and
    #what you want to name your output file (outputfile).
    inputfile = 'Greenland_vel_mosaic_250_vy_v1.tif'
    outputfile = 'Greenland_vel_mosaic_250_vy_v1.nc'
    #Do not change this line, the following command will convert the geoTIFF to a netCDF
    ds = gdal.Translate(outputfile, inputfile, format='NetCDF')