[gdal-dev] question for scaling default
Even Rouault
even.rouault at spatialys.com
Tue Aug 16 00:38:29 PDT 2022
Mike,
Le 14/08/2022 à 08:07, Michael Sumner a écrit :
> Hello, I have a new driver candidate, it's natively a type Byte and is
> a percentage (or fraction) floating point value when unscaled. I have
> a couple of questions. .
>
> https://github.com/OSGeo/gdal/pull/6183
>
> I'd like to have it unscale by default, with band type Float32 - but
> be able to opt out of scaling, and return the raw Byte type. I think
> that is a good default since most usage will want the fraction value,
> but occasionally useful to obtain the raw codes that include some
> special out of range values (>255).
>
> I think I can work out how to do this, but is there a driver that
> already provides this kind of behaviour that I can learn from?
I can't think of a driver that would do exactly that (some apply
unscaling but they do also the low-level I/O). As the rescaling involves
changing data type from raw Byte to unscaled Float32, I don't think that
NSIDCbinRasterBand can directly derive from RawRasterBand.
NSIDCbinRasterBand should probably have a RawRasterBand member variable
instead, and implement IReadBlock() to read in a temporary Byte buffer,
and apply the unscaling from it to the user provided buffer (or a bit
equivalently you could likely return a VRTRasterBand that would do the
unscaling, but this might not be more simple to setup, and if you want
to apply conditional unscaling dependending if values are out of range
or not, that would not be possible).
>
> Also, I feel like fraction (0, 1) is a more sensible data value than
> percentage (0, 100), although I've used percentage in the past with
> these data. Any thoughts, or examples that exist in GDAL?
I don't think there's a norm in GDAL for that. Different drivers or
different data products probably use both conventions. Having the
GetUnitType() method return "Percentage" or "Fraction [0,1]" should be
enough to document the behavior of the driver.
Even
--
http://www.spatialys.com
My software is free, but my time generally not.
More information about the gdal-dev
mailing list