[GRASSLIST:2631] Re: Where's the (attribute) data?

Soil & Water Lab. swlab at cornell.edu
Thu Nov 1 19:24:58 EST 2001


Hello,

> 1. Within GRASS (i.e., NOT linking to an exterior DBMS) are all GRASS
> maps (vector, site, and raster) limited to a single column of attribute
> data or can some (e.g., vector) have more than one data column
> associated?

If I have understood everything correctly, the structure of a map is a 
three-element array :
category number : category value : category label.
The first element must be an integer.
The second one can be a float (even if integers are far easier to deal with : 
displaying a float map takes far far longer than an integer map).
The first one can be whatever you want. For example, a string, that could 
correspond to a given line of your attribute table.
The pb you'll have is how to process this string.

A trick I found was to make as many maps as different attributes. You can 
automatize the creation of maps by the "r.reclass" command (for raster maps), 
if you use a file as reclass rule. In fact, reclassification rules are read 
from stdin : in other terms, you can pipe the result of a file procsseing 
tool like "gawk" to the "r.reclass" command :
Example (taken from a script I've written for my model)
gawk  -F";" '{ 
print $1,"=",$1,($16 != -9999 ? ($16-$9)/$14 : 0) }'MyAttributeTable | 
r.reclass input=MyInputMap output=MyOutputMap

Here, MyAttributeTable is just a semicolon-separated table.
The gawk command process each line of LPT, and output the first field of the 
table (the category number), the category value (set here to the same 
category number, and a label (taken as the result of some operations on some 
other fields of the table).
I only use the label, by calling @SDmdl.$i (please refer to the r.mapcalc 
command for more info...). But you could set the category value to any 
particular attribute (field in you table). It's just a trick to store float 
variable in integer maps...

Mmh. Guess I should have started by this : it may be really easier to process 
 a table of attributes, than trying to import them all in one map only. This 
table could be build from you files. 

> 2. - 3. - 4. - 5. - 6. 
Sorry no idea...

---
Pierre GM
------------------------------
Soil and Water Laboratory
Biological and Environmental Engineering Department
Cornell University
Riley-Robb Hall
ITHACA, NY 14853 - USA



More information about the grass-user mailing list