[GRASS-user] A better way to create color table out of
"GLC_EU_V2.clr" for r.colors
Hamish
hamish_b at yahoo.com
Tue Mar 18 02:25:12 EDT 2008
Nikos Alexandris wrote:
> 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
[...]
> 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
no need for the "0" rule?
> Is there a better/ shorter way?
sure, r.colors can read the original without need to convert "R G B"
to "R:G:B" or remove any extra spaces.
> 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.
awk '{print}'
or
sed -e 's/^[ ]*//'
or
sed -e 's/^\s*//'
or
sed -e 's/^[:space:]*//'
see http://www.regular-expressions.info
Hamish
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
More information about the grass-user
mailing list