[gdal-dev] gdal_translate into netCDF file will lose some important metadata items such as scale_factor and add_offset

Zhan Li zhanli1986 at gmail.com
Sun Aug 30 15:11:54 PDT 2020


Hi, when I use gdal_translate to convert a raster file (e.g., either GTiff
or VRT) into netCDF format, it always loses some important metadata items
such as scale_factor, add_offset and etc. What am I doing it wrong? Can
anyone help me to solve this problem?

Here I'm using an example NetCDF file from NOAA
<ftp://ftp.cdc.noaa.gov/Datasets/cmap/std/precip.mon.mean.nc> called "
precip.mon.mean.nc " to demo the problem.
First convert one band of the netCDF file into a GTiff file.
$ gdal_translate -of GTiff -b 1 precip.mon.mean.nc precip.mon.mean.b1.tif
$ gdalinfo precip.mon.mean.b1.tif
It returns the following 16 metadata items for the band in the following,

Band 1 Block=144x14 Type=Float32, ColorInterp=Gray
  NoData Value=-9.96920996838686905e+36
  Unit Type: mm/day
  Metadata:
    actual_range={0,59.080002}
    add_offset=0
    dataset=CPC Merged Analysis of Precipitation Standard
    least_significant_digit=2
    level_desc=Surface
    long_name=Average Monthly Rate of Precipitation
    missing_value=-9.96921e+36
    NETCDF_DIM_time=1569072
    NETCDF_VARNAME=precip
    parent_stat=Mean
    precision=2
    scale_factor=1
    statistic=Mean
    units=mm/day
    valid_range={0,70}
    var_desc=Precipitation

Now convert the GTiff back into a netCDF file
$ gdal_translate -of netCDF precip.mon.mean.b1.tif precip.mon.mean.b1.nc
$ gdalinfo precip.mon.mean.b1.nc
Now it returns only 12 metadata items which miss some particular important
ones such as scale_factor, add_offset, and etc.

Band 1 Block=144x1 Type=Float32, ColorInterp=Undefined
  NoData Value=-9.96920996838686905e+36
  Unit Type: mm/day
  Metadata:
    actual_range={0,59.080002}
    dataset=CPC Merged Analysis of Precipitation Standard
    least_significant_digit=2
    level_desc=Surface
    long_name=Average Monthly Rate of Precipitation
    NETCDF_VARNAME=precip
    parent_stat=Mean
    precision=2
    statistic=Mean
    units=mm/day
    var_desc=Precipitation
    _FillValue=-9.96921e+36

Thanks,

Zhan.

-- 
Zhan Li <https://zhanlilz.github.io/>, 李展;
Google Scholar
<https://scholar.google.com/citations?user=JGNL9BoAAAAJ&hl=en>,
ORCID <https://orcid.org/0000-0001-6307-5200>, Github
<https://github.com/zhanlilz>,
Twitter <https://twitter.com/zhanlilz>, LinkedIn
<https://www.linkedin.com/in/zhanli/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200831/3efe75e9/attachment.html>


More information about the gdal-dev mailing list