[GRASS-user] A better way to create color table out of "GLC_EU_V2.clr" for r.colors than: cat GLC_EU_V2.clr | head -28 | tail -25 | cut -d' ' -f2, 3, 4 | tr " " ":" | cat -n

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Mon Mar 17 15:50:27 EDT 2008


A file called GLC_EU_V2.clr (contains RGB color values) comes along with
EUv2_binary.zip (the Global Land Cover 2000).

It's structure is (output from "cat GLC_EU_V2.clr | head -30")
# value red green blue

0 0 0 0
1 0 99 0
2 0 150 0
3 175 255 99
4 140 68 17
5 204 127 96
6 140 191 0
7 119 150 255
8 0 71 198
9 0 229 0
10 0 0 0
11 255 119 0
12 255 178 0
13 255 234 158
14 221 201 160
15 0 150 150
16 255 224 229
17 255 117 232
18 201 137 255
19 181 181 181
20 137 226 255
21 239 239 239
22 255 0 0
23 255 183 193
24 255 255 255
25 255 255 255
26 0 0 0
27 0 0 0

[...]

255 0 0 0

---
I try to make a color table for r,colors out of this and I use:

command:
cat GLC_EU_V2.clr | head -28 | tail -25 | cut -d' ' -f2,3,4 | tr " " ":"
| cat -n

output (*note the spaces in front of each line):
     1  0:99:0
     2  0:150:0
     3  175:255:99
     4  140:68:17
     5  204:127:96
     6  140:191:0
     7  119:150:255
     8  0:71:198
     9  0:229:0
    10  0:0:0
    11  255:119:0
    12  255:178:0
    13  255:234:158
    14  221:201:160
    15  0:150:150
    16  255:224:229
    17  255:117:232
    18  201:137:255
    19  181:181:181
    20  137:226:255
    21  239:239:239
    22  255:0:0
    23  255:183:193
    24  255:255:255
    25  255:255:255
---

Is there a better/ shorter way? How can I eliminate the spaces in front
of each line (or how can I produce them better?)?

Probably "sed" holds the answer but it takes time to learn.

Thank you,

Nikos




More information about the grass-user mailing list