[GRASS-user] A color rules - a little issue

Glynn Clements glynn at gclements.plus.com
Mon Mar 19 11:15:17 EDT 2007


Jaros-Bław Jasiewicz wrote:-A

> I have a suggestion about color managment in grass
> I just work on couple of maps where I need to prepare custom color 
> schemes (rules). Using the r.colors.rules is slighty (Hmm... rather 
> strongly) uncomfortable.

Have you tried:

	r.colors map=... color=rules < rulesfile

?

> To omit it I replaced dir colors in ../grass63.cvs/etc/ dir with simlink 
> to dir in my home directory and I create new rule file every time I must 
> experiment with colors.
> 
> It is not good solution for two reason:
> 1) every new grass complilation makes problem with symlink
> 2) I have over 60 rules files in one directory and the number increase
> 
> Is possible to create solution similar to r.reclass.file to use custom 
> color rule file from anywhere in file system?

If you want to use the above from gis.m, save the attached script as
$GISBASE/etc/gm/script/r.colors.file, and add the following line to
$GISBASE/etc/gm/gmmenu.tcl near the one for r.colors.rules:

		{command {[G_msg "Set colors using rules file"]} {} "r.colors.file" {} -command {execute $env(GISBASE)/etc/gm/script/r.colors.file }}

Or you can make the changes in the source tree (replace
$GISBASE/etc/gm with gui/tcltk/gis.m in the above paths) if you want
them to survive "make install".

-- 
Glynn Clements <glynn at gclements.plus.com>

-------------- next part --------------
#!/bin/sh
#
############################################################################
#
# MODULE:	r.colors.file for GRASS 6.x
# AUTHOR(S):	Glynn Clements
# PURPOSE:	Read color rules for r.colors from a named file
# COPYRIGHT:	(C) 2007 by the GRASS Development Team
#
#		This program is free software under the GNU General Public
#		License (>=v2). Read the file COPYING that comes with GRASS
#		for details.
#
#############################################################################

#%Module
#%  description: r.colors.file - Use rules file to set colors for raster map
#%End
#%option
#% key: map
#% type: string
#% gisprompt: old,cell,raster
#% description: Name of raster map for color management
#% required : yes
#%end
#%Option
#% key: file
#% type: string
#% required: yes
#% multiple: no
#% key_desc: name
#% description: Name of rules file
#% gisprompt: old_file,file,input
#%End

if  [ -z "$GISBASE" ] ; then
 echo "You must be in GRASS GIS to run this program."
 exit 1
fi   

if [ "$1" != "@ARGS_PARSED@" ] ; then
  exec g.parser "$0" "$@"
fi

exec r.colors "map=$GIS_OPT_MAP" color=rules < "$GIS_OPT_FILE"


More information about the grass-user mailing list