[GRASS-user] A better way to create color table out of "GLC_EU_V2.clr" for r.colors

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Tue Mar 18 07:24:13 EDT 2008


On Mon, 2008-03-17 at 23:25 -0700, Hamish wrote:
> 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?
Not really since there is no class 0 - Look at my other e-mail
entitled... eehhmmm!! You already answered to that as well ;-)
> 
> > 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.
! I think I tried that... I am re-checking.

> 
> 
> > 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

Thank you Hamish :-)
> 
> 
> 
> Hamish
> 
> 
> 
>       ____________________________________________________________________________________
> Never miss a thing.  Make Yahoo your home page. 
> http://www.yahoo.com/r/hs
> 



More information about the grass-user mailing list