[GRASSLIST:445] creating legend file for vector map

Hi. I have imported using m.in.e00 e00 vector maps, and all the associated
categories have been imported and are stored in the dig_cats directory. I
would like to create a legend file (preferably have GRASS do this for me) so
that each category can de displayed with a different color and an
accompanying legend.

The only info I have found so far is that I would have to create this bt hand
using the category files, which seems to be quite cumbersome.

I hope there is another way to do this, and would appreciate any help. Thanks
in advance for your indulgence of a GRASS newbie.

--
k|J|f

On Friday 20 June 2003 15:00, Keith J. Forbes wrote:

KJ Hi. I have imported using m.in.e00 e00 vector maps, and all the
associated KJ categories have been imported and are stored in the dig_cats
directory. I KJ would like to create a legend file (preferably have GRASS
do this for me) so KJ that each category can de displayed with a different
color and an KJ accompanying legend.
KJ
KJ The only info I have found so far is that I would have to create this
bt hand KJ using the category files, which seems to be quite cumbersome.
KJ
KJ I hope there is another way to do this, and would appreciate any help.
Thanks KJ in advance for your indulgence of a GRASS newbie.
KJ
KJ
KJ

Well, I ended up doing this the hard way (by hand) by creating a legend file
(table like this without header row of course) to use with d.vect.area:

Cat. RGB
1 xxx xxx xxx
2 xxx xxy xxy
and so on

which worked fine after I got a RGB pallette from the web

Now, I would like to display a legend along with the colored map matching the
category labels to the colors.

Help!!!

Thanks.

--
k|J|f

Keith J. Forbes said:

Hi. I have imported using m.in.e00 e00 vector maps, and all the associated
categories have been imported and are stored in the dig_cats directory. I
would like to create a legend file (preferably have GRASS do this for me)
so
that each category can de displayed with a different color and an
accompanying legend.

The only info I have found so far is that I would have to create this bt
hand
using the category files, which seems to be quite cumbersome.

I hope there is another way to do this, and would appreciate any help.
Thanks
in advance for your indulgence of a GRASS newbie.

No, you will have to do it "by hand", but this could mean via a script.

As an example:

Using a vector file with 11 categories, numbered 1-11 according to the
importance of a specific phenomenon (1 being the most important and 11 the
least important), you could copy the dig_cats file corresponding to this
map into a working directory, there (within that copy) erase all the lines
before the first category, and use a script such as

awk 'BEGIN{FS=":"} {print $1, int($1*255/12), int($1*255/12),
int($1*255/12)}' ReworkedDig_CatsFile > legend.file

to create a grey scale legend.

If you play around with the "int($1*255/12)" parts, you can create
different color scales.
However, if you do not want scales but a specific color for each category,
then you will have to do this by hand...

Moritz

Keith J. Forbes said:

On Friday 20 June 2003 15:00, Keith J. Forbes wrote:

KJ Hi. I have imported using m.in.e00 e00 vector maps, and all the
associated KJ categories have been imported and are stored in the
dig_cats
directory. I KJ would like to create a legend file (preferably have
GRASS
do this for me) so KJ that each category can de displayed with a
different
color and an KJ accompanying legend.
KJ
KJ The only info I have found so far is that I would have to create
this
bt hand KJ using the category files, which seems to be quite
cumbersome.
KJ
KJ I hope there is another way to do this, and would appreciate any
help.
Thanks KJ in advance for your indulgence of a GRASS newbie.
KJ
KJ
KJ

Well, I ended up doing this the hard way (by hand) by creating a legend
file
(table like this without header row of course) to use with d.vect.area:

Cat. RGB
1 xxx xxx xxx
2 xxx xxy xxy
and so on

which worked fine after I got a RGB pallette from the web

Now, I would like to display a legend along with the colored map matching
the
category labels to the colors.

Help!!!

Well, the only way I know how you can do this is to create a new vector
file (in v.digit, for example) with as many areas (for example rectangles)
as you have categories, label each area with one of the category numbers
and apply your legend file to this new vector map.

If you create your legend file in v.digit, you can use the Customize ->
Select An Overlay vector Map option to overlay your base vector map in
order to place the legend at a convenient spot in relation to your base
vector map.

Moritz

Keith J. Forbes said:

On Friday 20 June 2003 17:08, you wrote:

ML Keith J. Forbes said:
ML > Hi. I have imported using m.in.e00 e00 vector maps, and all the
associated ML > categories have been imported and are stored in the
dig_cats directory. I ML > would like to create a legend file
(preferably
have GRASS do this for me) ML > so
ML > that each category can de displayed with a different color and an
ML > accompanying legend.
ML >
ML > The only info I have found so far is that I would have to create
this
bt ML > hand
ML > using the category files, which seems to be quite cumbersome.
ML >
ML > I hope there is another way to do this, and would appreciate any
help. ML > Thanks
ML > in advance for your indulgence of a GRASS newbie.
ML
ML No, you will have to do it "by hand", but this could mean via a
script.
ML
ML As an example:
ML
ML Using a vector file with 11 categories, numbered 1-11 according to
the
ML importance of a specific phenomenon (1 being the most important and
11
the ML least important), you could copy the dig_cats file corresponding
to
this ML map into a working directory, there (within that copy) erase
all
the lines ML before the first category, and use a script such as
ML
ML awk 'BEGIN{FS=":"} {print $1, int($1*255/12), int($1*255/12),
ML int($1*255/12)}' ReworkedDig_CatsFile > legend.file
ML
ML to create a grey scale legend.
ML
ML If you play around with the "int($1*255/12)" parts, you can create
ML different color scales.
ML However, if you do not want scales but a specific color for each
category, ML then you will have to do this by hand...
ML
ML Moritz
ML
ML

Hi Moritz,

Thanks for the script. I have been using Linux only a month longer than
Grass, so please be patient when I ask how I would go about messing with
the 255/12 parts to obtain a gradient of one color.

The legend file contains RGB values, i.e. red-green-blue, so for example

awk 'BEGIN{FS=":"} {print $1, int($1*255/12), "0", "0"}'
ReworkedDig_CatsFile > legend.file

would give you a red scale since green and blue would be set to 0.

Similarly,

awk 'BEGIN{FS=":"} {print $1, "0", int($1*255/12), "0"}'
ReworkedDig_CatsFile > legend.file

would give you a green scale, and

awk 'BEGIN{FS=":"} {print $1, "255" , int($1*255/12), "0"}'
ReworkedDig_CatsFile > legend.file

would give you a red to yellow scale, and

awk 'BEGIN{FS=":"} {print $1, "255" , 255-int($1*255/12), "0"}'
ReworkedDig_CatsFile > legend.file

a yellow to red scale.

Play around with the numbers to see what it gives you, or look at an rgb
color table and calculate the formulas you need.

Basically you should vary the 12 in 255/12 according to the number of
categories that you have, so it should be 255/n+1 or 255/n if you wish to
use the extremes of the color table (i.e. white and black if you use grey
scale).

Have fun !

Moritz

On Friday 20 June 2003 17:15, Moritz Lennert wrote:

ML Keith J. Forbes said:
ML >
ML >
ML >
ML > On Friday 20 June 2003 15:00, Keith J. Forbes wrote:
ML >> KJ Hi. I have imported using m.in.e00 e00 vector maps, and all the
ML >> associated KJ categories have been imported and are stored in the
ML >> dig_cats
ML >> directory. I KJ would like to create a legend file (preferably have
ML >> GRASS
ML >> do this for me) so KJ that each category can de displayed with a
ML >> different
ML >> color and an KJ accompanying legend.
ML >> KJ
ML >> KJ The only info I have found so far is that I would have to create
ML >> this
ML >> bt hand KJ using the category files, which seems to be quite
ML >> cumbersome.
ML >> KJ
ML >> KJ I hope there is another way to do this, and would appreciate any
ML >> help.
ML >> Thanks KJ in advance for your indulgence of a GRASS newbie.
ML >> KJ
ML >> KJ
ML >> KJ
ML >
ML >
ML >
ML > Well, I ended up doing this the hard way (by hand) by creating a
legend ML > file
ML > (table like this without header row of course) to use with
d.vect.area: ML >
ML > Cat. RGB
ML > 1 xxx xxx xxx
ML > 2 xxx xxy xxy
ML > and so on
ML >
ML > which worked fine after I got a RGB pallette from the web
ML >
ML > Now, I would like to display a legend along with the colored map
matching ML > the
ML > category labels to the colors.
ML >
ML > Help!!!
ML >
ML
ML Well, the only way I know how you can do this is to create a new vector
ML file (in v.digit, for example) with as many areas (for example
rectangles) ML as you have categories, label each area with one of the
category numbers ML and apply your legend file to this new vector map.
ML
ML If you create your legend file in v.digit, you can use the Customize ->
ML Select An Overlay vector Map option to overlay your base vector map in
ML order to place the legend at a convenient spot in relation to your base
ML vector map.
ML
ML Moritz
ML
ML

Thanks Moritz.

I have over 40 categories, and I tried digitizing a couple of rectangles and
found that the process of creating rectangles without leaks, labelling them,
etc. is quite cumbersome. There must be another way to get GRASS to use the
legend file I made by hand (2 columns of text, one with categories, and
another with RGB values) to make a legend box?

Can anyone help with this??? Thanks in advance.

Keith

--
k|J|f

Keith J. Forbes said:

On Friday 20 June 2003 17:15, Moritz Lennert wrote:

ML Keith J. Forbes said:
ML >
ML >
ML >
ML > On Friday 20 June 2003 15:00, Keith J. Forbes wrote:
ML >> KJ Hi. I have imported using m.in.e00 e00 vector maps, and all
the
ML >> associated KJ categories have been imported and are stored in
the
ML >> dig_cats
ML >> directory. I KJ would like to create a legend file (preferably
have
ML >> GRASS
ML >> do this for me) so KJ that each category can de displayed with a
ML >> different
ML >> color and an KJ accompanying legend.
ML >> KJ
ML >> KJ The only info I have found so far is that I would have to
create
ML >> this
ML >> bt hand KJ using the category files, which seems to be quite
ML >> cumbersome.
ML >> KJ
ML >> KJ I hope there is another way to do this, and would appreciate
any
ML >> help.
ML >> Thanks KJ in advance for your indulgence of a GRASS newbie.
ML >> KJ
ML >> KJ
ML >> KJ
ML >
ML >
ML >
ML > Well, I ended up doing this the hard way (by hand) by creating a
legend ML > file
ML > (table like this without header row of course) to use with
d.vect.area: ML >
ML > Cat. RGB
ML > 1 xxx xxx xxx
ML > 2 xxx xxy xxy
ML > and so on
ML >
ML > which worked fine after I got a RGB pallette from the web
ML >
ML > Now, I would like to display a legend along with the colored map
matching ML > the
ML > category labels to the colors.
ML >
ML > Help!!!
ML >
ML
ML Well, the only way I know how you can do this is to create a new
vector
ML file (in v.digit, for example) with as many areas (for example
rectangles) ML as you have categories, label each area with one of the
category numbers ML and apply your legend file to this new vector map.
ML
ML If you create your legend file in v.digit, you can use the Customize
->
ML Select An Overlay vector Map option to overlay your base vector map
in
ML order to place the legend at a convenient spot in relation to your
base
ML vector map.
ML
ML Moritz
ML
ML

Thanks Moritz.

I have over 40 categories, and I tried digitizing a couple of rectangles
and
found that the process of creating rectangles without leaks, labelling
them,
etc. is quite cumbersome. There must be another way to get GRASS to use
the
legend file I made by hand (2 columns of text, one with categories, and
another with RGB values) to make a legend box?

Can anyone help with this??? Thanks in advance.

I see two possibilities:

- Either you do what someone else already suggested, i.e. transforming
your vector map into raster and using d.legend (this is the classical
GRASS way).

- Or you can try v.in.poly to automatically create polygons (squares if
you use segments=4; play around with the radius parameter to find correct
size). With a little script you should be able to write an input file
containing coordinates for easily spaced squares (depending on your
projection and region), category number and description. If you apply your
color legend to these polygons you should have a legend.
However, I not too sure about the best way to place the text descriptions.
d.vect.labels unfortunately does not allow changing the offset of the
text, so it is placed directly onto the polygon. Other modules either only
work interactively, or you don't allow you to give a file containing the
text and coordinates for all labels. Maybe someone else can help you with
this.

Moritz

Hi Keith,
(cc to the grass-users list, so that other can profit from our discussions
:wink: )

Keith J. Forbes said:

Dear Moritz:

Thanks for sticking with this.

Ok. something is weird here and I think it has to do with the original
import of the e00 file (source of the data). I copied the attached file to
ecol, and then ran v.support.

I checked with v.info, and the other r ones, as you suggested, and there
are 547 cats not 43. Now, each of these cats which from the file created
in dig_cats is basically a different ecotype. I would like each ecotype to
appear as a unique color and in the legend.

GRASS texts can be a bit confusing in there use of the terms category and
attribute: the attribute or category NUMBER is stored in the dig_att file,
the LABELS (i.e. the descriptions) for the different attributes or
categories are stored in the dig_cats file.

So, when your file is imported, a dig_att file is created with
category/attribute numbers, that don't necessarily have to be unique.
Here's an example of the contents of such a file:

A 163027.7718230 151474.5355770 1
A 164207.9674190 172255.2677390 2
A 189804.7270340 238558.1220960 3
A 190347.9399790 238476.2118820 3

It is this file that is used for the definition of the categories in the
raster file. So if you have a dig_att file containing 547 different
category numbers, then v.to.rast will give you 547 different categories in
the resulting categories file.

m.in.e00 creates different dig_cats files for each seperate attribute it
finds in the e00 file. You correctly identified the one you're interested
in and copied it to ecol, but this concerns the labels or descriptions,
not the category numbers which are unique for each polygon.

I tried fooling GRASS by
creating a text file with columns as follows:

(normal header info)

1:ecotype1
1:ecotype1
2:ecotype2
2:ecotype2
2:ecotype2
3:ecotype3
3:ecotype3
and so on for all 547

and then running v.support

GRASS did not like this at all.

The numbers on the left should be unique and correspond to the numbers
used in the dig_att file, so it is normal that this doesn't work.

So, I am going to try r.reclass on the raster file, and, after changing
all values to zero, change all the values for the same ecotype to the same
number (from 2-43). Then, I will run d.legend to see if it works.

You need to use the dig_cats file to create reclass rules in order to make
your category labels into category numbers. See
http://op.gfz-potsdam.de/GRASS-List/Archive/msg08631.html for two
different solutions to this. However, as far as I can see, only the second
(the one in the cited section of the mail) will work if your labels in the
dig_cats file are text (as is your cas). But I might be wrong.

I hope this will solve your problems.

Moritz

On Wednesday 25 June 2003 09:39, Moritz Lennert wrote:

Hi Keith,
(cc to the grass-users list, so that other can profit from our discussions
:wink: )

Keith J. Forbes said:
> Dear Moritz:
>
> Thanks for sticking with this.
>
> Ok. something is weird here and I think it has to do with the original
> import of the e00 file (source of the data). I copied the attached file
> to ecol, and then ran v.support.
>
> I checked with v.info, and the other r ones, as you suggested, and there
> are 547 cats not 43. Now, each of these cats which from the file created
> in dig_cats is basically a different ecotype. I would like each ecotype
> to appear as a unique color and in the legend.

GRASS texts can be a bit confusing in there use of the terms category and
attribute: the attribute or category NUMBER is stored in the dig_att file,
the LABELS (i.e. the descriptions) for the different attributes or
categories are stored in the dig_cats file.

So, when your file is imported, a dig_att file is created with
category/attribute numbers, that don't necessarily have to be unique.
Here's an example of the contents of such a file:

A 163027.7718230 151474.5355770 1
A 164207.9674190 172255.2677390 2
A 189804.7270340 238558.1220960 3
A 190347.9399790 238476.2118820 3

It is this file that is used for the definition of the categories in the
raster file. So if you have a dig_att file containing 547 different
category numbers, then v.to.rast will give you 547 different categories in
the resulting categories file.

m.in.e00 creates different dig_cats files for each seperate attribute it
finds in the e00 file. You correctly identified the one you're interested
in and copied it to ecol, but this concerns the labels or descriptions,
not the category numbers which are unique for each polygon.

> I tried fooling GRASS by
> creating a text file with columns as follows:
>
>
> (normal header info)
>
> 1:ecotype1
> 1:ecotype1
> 2:ecotype2
> 2:ecotype2
> 2:ecotype2
> 3:ecotype3
> 3:ecotype3
> and so on for all 547
>
> and then running v.support
>
> GRASS did not like this at all.

The numbers on the left should be unique and correspond to the numbers
used in the dig_att file, so it is normal that this doesn't work.

> So, I am going to try r.reclass on the raster file, and, after changing
> all values to zero, change all the values for the same ecotype to the
> same number (from 2-43). Then, I will run d.legend to see if it works.

You need to use the dig_cats file to create reclass rules in order to make
your category labels into category numbers. See
http://op.gfz-potsdam.de/GRASS-List/Archive/msg08631.html for two
different solutions to this. However, as far as I can see, only the second
(the one in the cited section of the mail) will work if your labels in the
dig_cats file are text (as is your cas). But I might be wrong.

I hope this will solve your problems.

Moritz

Moritz: Hi again.
Tried the second method as you suggested from
http://op.gfz-potsdam.de/GRASS-List/Archive/msg08631.html
worked like a charm.

One question though. This process with the awk script and then using the file
with a unique identifier for each label as follows as the basis for v.reclass
and then v.support, would this be a much faster equivalent of a manual
interactive v.reclass or r.reclass, changing the value to the same unique
number for each label, and then running v.support?
--------
1=1 label1
2=1 label1
3=2 label2
4=2 label2
5=2 label2
to
547 (in this case)

and so on for all the "categories" created by GRASS during m.in.e00 import of
e00 file in a particular label file (in dig_cats directory)

Decided to get the GRASS book by Mitasova et al.!! My questions may be less
easy in the future. :wink:
-----------
--
k|J|f

Keith J. Forbes said:

On Wednesday 25 June 2003 09:39, Moritz Lennert wrote:

Hi Keith,
(cc to the grass-users list, so that other can profit from our
discussions
:wink: )

Keith J. Forbes said:
> Dear Moritz:
>
> Thanks for sticking with this.
>
> Ok. something is weird here and I think it has to do with the original
> import of the e00 file (source of the data). I copied the attached
file
> to ecol, and then ran v.support.
>
> I checked with v.info, and the other r ones, as you suggested, and
there
> are 547 cats not 43. Now, each of these cats which from the file
created
> in dig_cats is basically a different ecotype. I would like each
ecotype
> to appear as a unique color and in the legend.

GRASS texts can be a bit confusing in there use of the terms category
and
attribute: the attribute or category NUMBER is stored in the dig_att
file,
the LABELS (i.e. the descriptions) for the different attributes or
categories are stored in the dig_cats file.

So, when your file is imported, a dig_att file is created with
category/attribute numbers, that don't necessarily have to be unique.
Here's an example of the contents of such a file:

A 163027.7718230 151474.5355770 1
A 164207.9674190 172255.2677390 2
A 189804.7270340 238558.1220960 3
A 190347.9399790 238476.2118820 3

It is this file that is used for the definition of the categories in the
raster file. So if you have a dig_att file containing 547 different
category numbers, then v.to.rast will give you 547 different categories
in
the resulting categories file.

m.in.e00 creates different dig_cats files for each seperate attribute it
finds in the e00 file. You correctly identified the one you're
interested
in and copied it to ecol, but this concerns the labels or descriptions,
not the category numbers which are unique for each polygon.

> I tried fooling GRASS by
> creating a text file with columns as follows:
>
>
> (normal header info)
>
> 1:ecotype1
> 1:ecotype1
> 2:ecotype2
> 2:ecotype2
> 2:ecotype2
> 3:ecotype3
> 3:ecotype3
> and so on for all 547
>
> and then running v.support
>
> GRASS did not like this at all.

The numbers on the left should be unique and correspond to the numbers
used in the dig_att file, so it is normal that this doesn't work.

> So, I am going to try r.reclass on the raster file, and, after
changing
> all values to zero, change all the values for the same ecotype to the
> same number (from 2-43). Then, I will run d.legend to see if it works.

You need to use the dig_cats file to create reclass rules in order to
make
your category labels into category numbers. See
http://op.gfz-potsdam.de/GRASS-List/Archive/msg08631.html for two
different solutions to this. However, as far as I can see, only the
second
(the one in the cited section of the mail) will work if your labels in
the
dig_cats file are text (as is your cas). But I might be wrong.

I hope this will solve your problems.

Moritz

Moritz: Hi again.
Tried the second method as you suggested from
http://op.gfz-potsdam.de/GRASS-List/Archive/msg08631.html
worked like a charm.

One question though. This process with the awk script and then using the
file
with a unique identifier for each label as follows as the basis for
v.reclass
and then v.support, would this be a much faster equivalent of a manual
interactive v.reclass or r.reclass, changing the value to the same unique
number for each label, and then running v.support?
--------
1=1 label1
2=1 label1
3=2 label2
4=2 label2
5=2 label2
to
547 (in this case)

and so on for all the "categories" created by GRASS during m.in.e00 import
of
e00 file in a particular label file (in dig_cats directory)

I'm not sure I understand your question correctly. To me it seems obvious
that typing one command line with the awk script would be faster than
typing every single reclass rule myself...

Decided to get the GRASS book by Mitasova et al.!! My questions may be
less
easy in the future. :wink:

No, you'll start answering those of the others :wink:

Moritz

On Thursday 26 June 2003 09:08, Moritz Lennert wrote:

Keith J. Forbes said:
> On Wednesday 25 June 2003 09:39, Moritz Lennert wrote:
>> Hi Keith,
>> (cc to the grass-users list, so that other can profit from our
>> discussions
>> :wink: )
>>
>> Keith J. Forbes said:
>> > Dear Moritz:
>> >
>> > Thanks for sticking with this.
>> >
>> > Ok. something is weird here and I think it has to do with the original
>> > import of the e00 file (source of the data). I copied the attached
>>
>> file
>>
>> > to ecol, and then ran v.support.
>> >
>> > I checked with v.info, and the other r ones, as you suggested, and
>>
>> there
>>
>> > are 547 cats not 43. Now, each of these cats which from the file
>>
>> created
>>
>> > in dig_cats is basically a different ecotype. I would like each
>>
>> ecotype
>>
>> > to appear as a unique color and in the legend.
>>
>> GRASS texts can be a bit confusing in there use of the terms category
>> and
>> attribute: the attribute or category NUMBER is stored in the dig_att
>> file,
>> the LABELS (i.e. the descriptions) for the different attributes or
>> categories are stored in the dig_cats file.
>>
>> So, when your file is imported, a dig_att file is created with
>> category/attribute numbers, that don't necessarily have to be unique.
>> Here's an example of the contents of such a file:
>>
>> A 163027.7718230 151474.5355770 1
>> A 164207.9674190 172255.2677390 2
>> A 189804.7270340 238558.1220960 3
>> A 190347.9399790 238476.2118820 3
>>
>> It is this file that is used for the definition of the categories in the
>> raster file. So if you have a dig_att file containing 547 different
>> category numbers, then v.to.rast will give you 547 different categories
>> in
>> the resulting categories file.
>>
>> m.in.e00 creates different dig_cats files for each seperate attribute it
>> finds in the e00 file. You correctly identified the one you're
>> interested
>> in and copied it to ecol, but this concerns the labels or descriptions,
>> not the category numbers which are unique for each polygon.
>>
>> > I tried fooling GRASS by
>> > creating a text file with columns as follows:
>> >
>> >
>> > (normal header info)
>> >
>> > 1:ecotype1
>> > 1:ecotype1
>> > 2:ecotype2
>> > 2:ecotype2
>> > 2:ecotype2
>> > 3:ecotype3
>> > 3:ecotype3
>> > and so on for all 547
>> >
>> > and then running v.support
>> >
>> > GRASS did not like this at all.
>>
>> The numbers on the left should be unique and correspond to the numbers
>> used in the dig_att file, so it is normal that this doesn't work.
>>
>> > So, I am going to try r.reclass on the raster file, and, after
>>
>> changing
>>
>> > all values to zero, change all the values for the same ecotype to the
>> > same number (from 2-43). Then, I will run d.legend to see if it works.
>>
>> You need to use the dig_cats file to create reclass rules in order to
>> make
>> your category labels into category numbers. See
>> http://op.gfz-potsdam.de/GRASS-List/Archive/msg08631.html for two
>> different solutions to this. However, as far as I can see, only the
>> second
>> (the one in the cited section of the mail) will work if your labels in
>> the
>> dig_cats file are text (as is your cas). But I might be wrong.
>>
>> I hope this will solve your problems.
>>
>> Moritz
>
> Moritz: Hi again.
> Tried the second method as you suggested from
> http://op.gfz-potsdam.de/GRASS-List/Archive/msg08631.html
> worked like a charm.
>
> One question though. This process with the awk script and then using the
> file
> with a unique identifier for each label as follows as the basis for
> v.reclass
> and then v.support, would this be a much faster equivalent of a manual
> interactive v.reclass or r.reclass, changing the value to the same unique
> number for each label, and then running v.support?
> --------
> 1=1 label1
> 2=1 label1
> 3=2 label2
> 4=2 label2
> 5=2 label2
> to
> 547 (in this case)
>
>
> and so on for all the "categories" created by GRASS during m.in.e00
> import of
> e00 file in a particular label file (in dig_cats directory)

I'm not sure I understand your question correctly. To me it seems obvious
that typing one command line with the awk script would be faster than
typing every single reclass rule myself...

> Decided to get the GRASS book by Mitasova et al.!! My questions may be
> less
> easy in the future. :wink:

No, you'll start answering those of the others :wink:

Moritz

Moritz:

The question was not regarding which method was faster! It was whether they
were equivalent in terms of results, and I deduce by your answer that they
are!

--
k|J|f

I don't have an access to the CVS tree due to a new provider, but I think
the following text must be put on the m.in.e00 manpage... (Markus, do you
hear me ? :wink:

It is often desirable to use one of the original object attributes as value
in the dig_att file (ex: elevation for contour lines, so you can made a dem,
etc.)

As a reminder : If ther is only one attribute (other than the standard ESRI
attributes for lines or areas), ther is only one dig_cats file created, and
its name is like the dig file name. If there is many attributes, there is
as many dig_cats files, named <vector_file_name>.<attribute_name>. In this case
the first thing to do is to go in the dig_cats directory and set a symbolic
link to the dig_cats file you want as the new dig_att values.

After that, you need only a two line command to change the att values. The
best is to take an example :

dig file name is brucom,
dig_att/brucom looks like :

# 48 categories
brucom

0.00 0.00 0.00 0.00
1:67482
2:67492
3:67354
4:67240
etc.

What you have to type :

export LOCATION=<your mpaset location>
sed -e '1,4d' -e 's/:confused: = /' $LOCATION/dig_cats/brucom | v.reclass input=brucom output=brucom1 type=area
v.support brucom1

The first line was added since $LOCATION is no longer set at grass startup...
The second one do the job : sed convert the dig_att file in a form usable by
v.reclass. You have to change
  - the file names and the location (obviously)
  - the type=area in type=line if you have lines instead of areas

The third line is mandatory for some other programs to work (v.digit, d.what.vect,
etc.)

To test the result, you can try

d.vect brucom
d.vect brucom1
d.what.vect

pointing on the map you should see something like :

Buttons
  Left: what's here
  Right: quit

987993.15898251(E) 1105829.10174881(N)
brucom1 in PERMANENT Area - Category 67212
Size - Sq Meters: 7287843.886 Hectares: 728.784
            Acres: 1800.822 Sq Miles: 2.8138
  brucom in PERMANENT Area - Category 37 67212
Size - Sq Meters: 7287843.886 Hectares: 728.784
            Acres: 1800.822 Sq Miles: 2.8138

984231.52146264(E) 1107780.62798092(N)
brucom1 in PERMANENT Area - Category 67554
Size - Sq Meters: 7487888.438 Hectares: 748.789
            Acres: 1850.253 Sq Miles: 2.8910
  brucom in PERMANENT Area - Category 33 67554
Size - Sq Meters: 7487888.438 Hectares: 748.789
            Acres: 1850.253 Sq Miles: 2.8910

You can see that the new file reflects what you wanted...

--
Michel Wurtz - Auzeville-Tolosane

Michel Wurtz said:

I don't have an access to the CVS tree due to a new provider, but I think
the following text must be put on the m.in.e00 manpage... (Markus, do you
hear me ? :wink:

It is often desirable to use one of the original object attributes as
value
in the dig_att file (ex: elevation for contour lines, so you can made a
dem,
etc.)

As a reminder : If ther is only one attribute (other than the standard
ESRI
attributes for lines or areas), ther is only one dig_cats file created,
and
its name is like the dig file name. If there is many attributes, there is
as many dig_cats files, named <vector_file_name>.<attribute_name>. In
this case
the first thing to do is to go in the dig_cats directory and set a
symbolic
link to the dig_cats file you want as the new dig_att values.

After that, you need only a two line command to change the att values.
The
best is to take an example :

dig file name is brucom,
dig_att/brucom looks like :

# 48 categories
brucom

0.00 0.00 0.00 0.00
1:67482
2:67492
3:67354
4:67240
etc.

What you have to type :

export LOCATION=<your mpaset location>
sed -e '1,4d' -e 's/:confused: = /' $LOCATION/dig_cats/brucom | v.reclass

A question: if I interpret this script correctly, it will only work, if
the attribute label in the dig_cats file created by m.in.e00 is an
integer. However, if it is a text label, this will not work.
The awk script proposed in
http://op.gfz-potsdam.de/GRASS-List/Archive/msg08631.html seems to solve
this problem.
So maybe we should propose that instead, or in addition ?

Moritz

Moritz Lennert wrote:

A question: if I interpret this script correctly, it will only work, if
the attribute label in the dig_cats file created by m.in.e00 is an
integer. However, if it is a text label, this will not work.

Yes, but this is a "feature" of grass vector files...

The awk script proposed in
http://op.gfz-potsdam.de/GRASS-List/Archive/msg08631.html seems to solve
this problem.

Hmm... I don't really understand what this script add. I believe that
using a symbolic link on the text label file for the dig_cats file gives
the same result as the script... (except that it will not create another
vector file).

The solution imho is to switch to grass5.1, where attributes are far
better handled.

--
Michel Wurtz - Auzeville-Tolosane

Michel Wurtz said:

Moritz Lennert wrote:

A question: if I interpret this script correctly, it will only work, if
the attribute label in the dig_cats file created by m.in.e00 is an
integer. However, if it is a text label, this will not work.

Yes, but this is a "feature" of grass vector files...

The awk script proposed in
http://op.gfz-potsdam.de/GRASS-List/Archive/msg08631.html seems to solve
this problem.

Hmm... I don't really understand what this script add. I believe that
using a symbolic link on the text label file for the dig_cats file gives
the same result as the script... (except that it will not create another
vector file).

Imagine you have a file with 1000 polygons representing soils. Each
polygon belongs to one of 40 soil categories. However, these categories
are identified with text codes. m.in.e00 will give you a dig_att file with
1000 lines and 1000 category numbers and a dig_cats file with 1000 lines
linking each of the 1000 categories to one of the 40 soil types. However,
if you want to create a map with 40 different colors representing these 40
different soil types, you will need to each of the polygons attributed to
one of 40 categories, not to one of 1000. Since you can't just use the
text attributes to do that, you have to transform the 40 soil types into
40 unique category numbers and link avery polygon to one of these numbers
in a dig_att file. The corresponding dig_cats file will then link those 40
numbers to the 40 textual soil types.

If I understand correctly, this is what the awk script does, whereas the
sed script doesn't.

The solution imho is to switch to grass5.1, where attributes are far
better handled.

True, but people might not feel comfortable to do so, yet, especially
since some features are still lacking.

Moritz

Moritz Lennert wrote:
[...]

one of 40 categories, not to one of 1000. Since you can't just use the
text attributes to do that, you have to transform the 40 soil types into
40 unique category numbers and link avery polygon to one of these numbers
in a dig_att file. The corresponding dig_cats file will then link those 40
numbers to the 40 textual soil types.

If I understand correctly, this is what the awk script does, whereas the
sed script doesn't.

You're right. I didn't make the point... BTW, this is probably something
to take in consideration when porting v.reclass to 5.1 : It should do this
kind of thing without the need of an awk script...

--
Michel Wurtz - Auzeville-Tolosane