[Qgis-developer] min/max for rasters

Vincent Schut schut at sarvision.nl
Sun Dec 15 23:41:27 PST 2013


On 12/14/13 07:17, Paolo Cavallini wrote:
> Il 13/12/2013 20:18, Radim Blazek ha scritto:
>
>>> Can you describe some examples where 2-98% is a problem (data type,
>>> number of bands, map content, features/phenomena represented by those
>>> 2+2%,...) so that we can think about it better?
> Example #1 (less problematic): dtm and their legend are always shown
> wrong; newbies do not understand why
> Example #2 (more serious): rasterizing sparse vectors (e.g. rivers)
> results in a black rectangle, as the number of pixels with valid data is
> <2%.
>
> In fact, I think we should help users more, e.g. by applying non linear
> colour scaling (log, exp)  in case of very skewed raster values
> distribution: if data are more or less normally distributed, no cut is
> applied, and linear scaling is used; if they are badly skewdw or with
> outliers, apply a non linear colour scaling. With some thinking, this
> should solve most if not all user cases, without asking a normal user to
> understand much about raster stats.
>
> However, in my case the general setting "use min/max" does not seem to
> be working.
> Thanks for your thoughts.
>
Imho, a lot could be derived from the image metadata: datatype, number 
of bands, 'photographic interpretation', etc.

- for 3 bands, 8 bit, assume rgb and do not stretch
- for 4 bands, 8 bit, assume rgba and do not stretch
- more bands and/or datatypes >8bit or float: usually means satellite 
imagery. I'd say, start with a stretch of 2-98%. Users of satellite 
imagery mostly know what to do when their image then still appears 
black, I think?
- 1 band data, >8bit: probably conitnuous data, possibly a dtm/dem, 
apply a stretch, maybe also 2-98 %? Of course all nodata pixels should 
be excluded from the 2-98% calculations.
- 1 band data, 8bit: probably sparse or 'class' data: discrete, might 
have lots of actual nodata values. A good default strategy might be to 
apply a random or default colormap.

Personally, I would refrain from non-linear stretch types as default. 
When I open a raster, I do not want too much 'intelligence' to happen. 
Also, I usually find the x-y% type of stretching more useful than the -x 
+y stdev type of streching, but that might have to do with the datasets 
I usually work with.

Problems of course arise when people/programs do not correctly set 
nodata values, etc. (e.g. in the case of rasterizing sparse vectors, all 
other pixels should be nodata). I'd say, do not build in too much 
intelligence to correct for things like that, in the end it only makes 
things more complicated.

My 2 cents.

Best,
Vincent Schut.


More information about the Qgis-developer mailing list