[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
Tue Sep 1 08:29:32 PDT 2020


Hi Even,

Thanks for such a quick fix! Really really appreciate what you've done for
the GDAL community!

Zhan.


On Mon, Aug 31, 2020 at 8:32 PM Even Rouault <even.rouault at spatialys.com>
wrote:

> Zhan,
>
>
>
> adding back the list
>
>
>
> There was an issue in the writing code of the netCDF driver. It was
> supposed supposed to copy the offset and scale settings from the source
> dataset, but there was a logic error. Fixed per
>
> https://github.com/OSGeo/gdal/pull/2906
>
>
>
> Even
>
>
>
>
>
> > Hi Even,
>
> >
>
> > Thanks a lot for your reply! Yes here in this example, scale_factor and
>
> > add_offset do not matter. I put them here just for demo purposes. In my
>
> > actual data (quite large), I'd like to use 1e-3 as scale factor but could
>
> > not write scale_factor into the metadata of netCDF via gdal_translate.
> Even
>
> > if I use VRT as an intermediate file and manually add scale_factor into
> the
>
> > VRT per band through "<MDI key="scale_factor">1e-3</MDI>". It still does
>
> > not work :(
>
> >
>
> > But it sounds like the implementation of the netCDF driver in GDAL has
> some
>
> > explicit tweak of metadata items? Like you said, valid_range is
> explicitly
>
> > discarded. Maybe scale_factor and add_offset and such are also part of
>
> > metadata items that the driver explicitly discards? In that case, I'll
>
> > stick to scale_factor=1 and add_offset=0. Not ideal though. Otherwise,
> this
>
> > loss of metadata items for netCDF files should count as a bug to be
>
> > reported?
>
> >
>
> > Zhan.
>
> >
>
> > On Mon, Aug 31, 2020 at 11:06 AM Even Rouault <
> even.rouault at spatialys.com>
>
> >
>
> > wrote:
>
> > > On lundi 31 août 2020 00:11:54 CEST Zhan Li wrote:
>
> > > > 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?
>
> > >
>
> > > As scale_factor=1 and add_offset=0 in that dataset, they have no
> effect,
>
> > > and are thus not stored when converted to GeoTIFF.
>
> > >
>
> > >
>
> > >
>
> > > valid_range is explicitly discarded from source metadata when
> converting
>
> > > into netCDF. I'm not completely sure of the rationale for that.
>
> > >
>
> > >
>
> > >
>
> > > Even
>
> > >
>
> > >
>
> > >
>
> > > --
>
> > >
>
> > > Spatialys - Geospatial professional services
>
> > >
>
> > > http://www.spatialys.com
>
>
>
>
>
> --
>
> Spatialys - Geospatial professional services
>
> http://www.spatialys.com
>


-- 
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/20200901/67ce678f/attachment.html>


More information about the gdal-dev mailing list