<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">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? <br></div><div dir="ltr"><div><br></div>Here I'm using <a href="ftp://ftp.cdc.noaa.gov/Datasets/cmap/std/precip.mon.mean.nc" target="_blank">an example NetCDF file from NOAA</a> called "
<a href="http://precip.mon.mean.nc">precip.mon.mean.nc</a>
" to demo the problem.<div>First convert one band of the netCDF file into a GTiff file.<br><div><div>$ gdal_translate -of GTiff -b 1 <a href="http://precip.mon.mean.nc">precip.mon.mean.nc</a> precip.mon.mean.b1.tif<br></div><div><div>$ gdalinfo precip.mon.mean.b1.tif</div><div>It returns the following 16 metadata items for the band in the following, </div><div><br></div><div>Band 1 Block=144x14 Type=Float32, ColorInterp=Gray<br> NoData Value=-9.96920996838686905e+36<br> Unit Type: mm/day<br> Metadata:<br> actual_range={0,59.080002}<br> add_offset=0<br> dataset=CPC Merged Analysis of Precipitation Standard<br> least_significant_digit=2<br> level_desc=Surface<br> long_name=Average Monthly Rate of Precipitation<br> missing_value=-9.96921e+36<br> NETCDF_DIM_time=1569072<br> NETCDF_VARNAME=precip<br> parent_stat=Mean<br> precision=2<br> scale_factor=1<br> statistic=Mean<br> units=mm/day<br> valid_range={0,70}<br> var_desc=Precipitation<br></div><div><br></div><div>Now convert the GTiff back into a netCDF file </div><div>$ gdal_translate -of netCDF precip.mon.mean.b1.tif <a href="http://precip.mon.mean.b1.nc">precip.mon.mean.b1.nc</a></div><div>$ gdalinfo <a href="http://precip.mon.mean.b1.nc">precip.mon.mean.b1.nc</a></div><div>Now it returns only 12 metadata items which miss some particular important ones such as scale_factor, add_offset, and etc. </div><div><br></div><div>Band 1 Block=144x1 Type=Float32, ColorInterp=Undefined<br> NoData Value=-9.96920996838686905e+36<br> Unit Type: mm/day<br> Metadata:<br> actual_range={0,59.080002}<br> dataset=CPC Merged Analysis of Precipitation Standard<br> least_significant_digit=2<br> level_desc=Surface<br> long_name=Average Monthly Rate of Precipitation<br> NETCDF_VARNAME=precip<br> parent_stat=Mean<br> precision=2<br> statistic=Mean<br> units=mm/day<br> var_desc=Precipitation<br> _FillValue=-9.96921e+36<br></div><div><br></div><div>Thanks, </div><div><br></div><div>Zhan.</div></div></div></div></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><a href="https://zhanlilz.github.io/" target="_blank">Zhan Li</a>, 李展; </div><div><a href="https://scholar.google.com/citations?user=JGNL9BoAAAAJ&hl=en" target="_blank">Google Scholar</a>, </div><div><a href="https://orcid.org/0000-0001-6307-5200" target="_blank">ORCID</a>, <a href="https://github.com/zhanlilz" target="_blank">Github</a>, </div><div><a href="https://twitter.com/zhanlilz" target="_blank">Twitter</a>, <a href="https://www.linkedin.com/in/zhanli/" target="_blank">LinkedIn</a></div></div></div></div></div></div></div>