[GRASS-dev] [GRASS GIS] #256: r.colors enhancement

#256: r.colors enhancement
-----------------------------------+----------------------------------------
Reporter: wegmann | Owner: grass-dev@lists.osgeo.org
     Type: enhancement | Status: new
Priority: trivial | Milestone: 6.4.0
Component: default | Version: 6.3.0
Keywords: r.colors colors range | Platform: Linux
      Cpu: Unspecified |
-----------------------------------+----------------------------------------
I had the problem that I wanted to display 5 related raster which have
different range of values (e.g. raster1: 0-10; raster2: 5-15; raster3:
6-17 etc.) with the same legend (bgyr) so that raster1 is mainly colored
in blue, while raster3 has more green/yellow colors and so on.

I managed it with a script and it is also possible by defining the color
rules by hand but adding a flag and add all related raster to a r.colors
command would be very handy:

r.colors map=raster1 raster=raster1,raster2,raster3 col=bgyr -newflag

-newflag would scale the colors of raster1 to the range of colors provided
by the values of all rasters. Perhaps it is also possible to add 'g.mlist
...' like in r.series for this feature.

Martin

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/256&gt;
GRASS GIS <http://grass.osgeo.org>

#256: r.colors enhancement
--------------------------+-------------------------------------------------
  Reporter: wegmann | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: trivial | Milestone: 6.4.0
Component: Raster | Version: 6.3.0
Resolution: | Keywords: r.colors colors range
  Platform: Linux | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by hamish):

  * component: default => Raster

Comment:

the "official" method for this would be something like:

{{{
for MAP in `g.mlist ...` ; do
   r.info -r $MAP
done
# find max/min range

r.colors map=raster1 color=rules << EOF
$MIN blue
$MIN+($MAX-$MIN)*0.33333 green
$MIN+($MAX-$MIN)*0.66667 yellow
$MAX red
EOF

r.colors map=raster2 rast=raster1
r.colors map=raster3 rast=raster1
r.colors map=raster4 rast=raster1
}}}

or create a dummy map containing the full range and use color=bgyr.

then show full range in legend with:

{{{
d.legend raster1 range=$MIN,$MAX
}}}

ok, so not at all optimal.

* <tt>raster=raster1,raster2,raster3</tt> perverts the meaning of the
raster= option.. :frowning:

* I don't really get the purpose of -newflag. Isn't that redundant?

Just on a pedantic note, I would point out that bcyr is superior to bgyr
as it follows a more linear transition through the color cube. :wink:

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/256#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#256: r.colors enhancement
--------------------------+-------------------------------------------------
  Reporter: wegmann | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: trivial | Milestone: 6.4.0
Component: Raster | Version: 6.3.0
Resolution: | Keywords: r.colors colors range
  Platform: Linux | Cpu: Unspecified
--------------------------+-------------------------------------------------
Comment (by glynn):

Replying to [ticket:256 wegmann]:

> but adding a flag and add all related raster to a r.colors command would
be very handy:
>
> r.colors map=raster1 raster=raster1,raster2,raster3 col=bgyr -newflag
>
> -newflag would scale the colors of raster1 to the range of colors
provided by the values of all rasters.

If you're only interested in the range, adding minimum= and maximum=
options would be a better approach.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/256#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#256: r.colors enhancement
--------------------------+-------------------------------------------------
  Reporter: wegmann | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: trivial | Milestone: 6.4.0
Component: Raster | Version: 6.3.0
Resolution: | Keywords: r.colors colors range
  Platform: Linux | Cpu: Unspecified
--------------------------+-------------------------------------------------
Comment (by wegmann):

yes that's right, just defining the range would be fine.

BTW is it possible to extract automatically the min/max values of a range
of rasters with another module (like r.univar)? So that the user knows the
range.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/256#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#256: r.colors enhancement
--------------------------+-------------------------------------------------
  Reporter: wegmann | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: trivial | Milestone: 6.4.0
Component: Raster | Version: 6.3.0
Resolution: | Keywords: r.colors colors range
  Platform: Linux | Cpu: Unspecified
--------------------------+-------------------------------------------------
Comment (by glynn):

Replying to [comment:3 wegmann]:

> BTW is it possible to extract automatically the min/max values of a
range of rasters with another module (like r.univar)? So that the user
knows the range.

You can do it for a single map with "r.info -r". For multiple maps, you
could use e.g.:
{{{
eval `for map in $maps ; do r.info -r $map ; done | sed 's/^.*=//' | sort
-n | sed -n -e '1s/^/min=/p;$s/^/max=/p'`
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/256#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#256: r.colors user settable min=, max=
--------------------------+-------------------------------------------------
  Reporter: wegmann | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: trivial | Milestone: 6.5.0
Component: Raster | Version: 6.3.0
Resolution: | Keywords: r.colors colors range
  Platform: Linux | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by hamish):

  * summary: r.colors enhancement => r.colors user settable min=, max=
  * milestone: 6.4.0 => 6.5.0

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/256#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>