[GRASS5] d.vect.area

M Lennert fa1079 at qmul.ac.uk
Fri Feb 1 07:20:18 EST 2002

> Date: Thu, 31 Jan 2002 08:02:55 -0800
> From: "Eric G. Miller" <egm2 at jps.net>
> To: grass5 at grass.itc.it
> Subject: Re: [GRASS5] d.vect.area
> I, personally, wanted to be able to save a color scheme after
> deciding on it, and be able to easily reuse it.  That's the main
> reason (selfish, I know).  I might be talked into the "catnum"
> argument, but that approach isn't very amenable to more than
> a few categories (there's a limit on command line argument
> length).  Also, I'd think about having your script generate a
> "legend" file that the user could save for reuse. Besides,
> the performance hit of generating even a temporary file is
> probably insubstantial compared to iterating through the
> dataset multiple times to draw each color.  Color lookups
> in d.vect.area should be pretty fast even for a very
> large number of categories (unlike the raster color lookups,
> I'm using a balanced tree which scales well).

As you could see from the other mails, Glynn convinced me of your approach. So, here's a new 
version of d.area.class (or whatever we should call it).

It now has two more optional parameters :

Usage: d.area.class map=name catfile=name 
classes=boundary1[,boundary2,..] [colfile=name] [reclass=name]"

           map = vector map to display
       catfile = variable file with 2 columns seperated by 
whitespace: 1=category 2=variable by which to class
       classes = class boundaries separated by comma (but no 
whitespaces), starting with boundary between class 1 and 2 and ending 
with boundary between class max-1 and max
       colfile = name of the file into which you wish to save the 
color legend file
       reclass = name of the file into which you wish to save the 
reclass rules

So, if the user gives a 'colfile' parameter, the script will store 
the color legend in the given file name, and if she/he gives a 
'reclass', the script will create a reclass rules file on the basis 
of the class boundaries given.

> I was also thinking about creating some palettes for the
> "random" color option (and perhaps making it really random).
> The standard GRASS colors are fairly boring.  

Is it possible to access the predefined palettes (greyscales, red to green, etc) from the shell ? 
And if not, how are they implemented (i.e. how to create color scale dynamically depending on 
the number of categories) ? A hint to the relevant places in the source code would be enough.

BTW, does anyone find this script useful ? I've always found the reclassifation a bit tedious, 
especially when you just want to quickly test some class boundaries.

I'm presently planning a script/module that would actually decide on the class boundaries for the 
user according to certain indications, such as number of classes and type of classification (i.e. 
natural breaks, arithmetic, geometrical, etc). I will soon receive some fortran code implementing 
this, so I'll try to reimplement it in C. Something to try my programming on without hurting 
anyone too much ;-)


More information about the grass-dev mailing list