[GRASS5] Updated d.vect.thematic

OK,

I’ve managed to add the option to save as a GIS Manager group (Thanks go to Daniel for helping with parsing rgb into hex). I think this deals with most of the suggestions and updates that everyone made. Thanks to you all.

I’m at home today and don’t have access to the CVS. I’ll update this tomorrow, along with an update to the GIS Manager menu that includes the thematic mapper.

Michael


C. Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
PO Box 872402
Arizona State University
Tempe, AZ 85287-2402
USA

Phone: 480-965-6262
Fax: 480-965-7671
www: <www.public.asu.edu/~cmbarton>

(attachments)

d.vect.thematic (24.4 KB)

On Mon, May 23, 2005 19:07, Michael Barton said:

OK,

I¹ve managed to add the option to save as a GIS Manager group (Thanks go to
Daniel for helping with parsing rgb into hex). I think this deals with most
of the suggestions and updates that everyone made. Thanks to you all.

I get the following error when trying to load the group file (I've attached
the group file for info). Seems that the color codes are not completely
correct:

invalid color name "# 0 0FA"
invalid color name "# 0 0FA"
    (processing "-fill" option)
    invoked from within
"$leg create rectangle $x1 $y1 $x2 $y2 -outline $opt($id,color) -fill
$opt($id,fcolor)"
    (procedure "DmVector::legend" line 41)
    invoked from within
"DmVector::legend $id"
    (procedure "DmVector::set_option" line 7)
    invoked from within
"DmVector::set_option $current_node $key $val"
    ("vector" arm line 2)
    invoked from within
"switch $type {
          group {
        DmGroup::set_option $current_node $key $val
          }
          raster {
        DmRaster::set_option $current_node $key $..."
    ("default" arm line 8)
    invoked from within
"switch $key {
        Group {

      if { [regexp -- {^File (.+)} $val r leftover] && ($leftover !=
      $::Dm::filename)} {
            set val "<-- $leftover"..."
    (procedure "Dm::load" line 46)
    invoked from within
"Dm::load $::Dm::filename_new"
    (procedure "Dm::OpenFileBox" line 20)
    invoked from within
"Dm::OpenFileBox .mainframe.topf.tb1"
    ("uplevel" body line 1)
    invoked from within
"uplevel \#0 $cmd"
    (procedure "Button::_release" line 18)
    invoked from within
"Button::_release .mainframe.topf.tb1.bbox2.b1"
    (command bound to event)

(attachments)

comcods.dm (2.47 KB)

Hi Moritz,

Try to find the spots in the code having things like 'printf("#%2X%2X' in the
awk code and change each of those "%2X" to "%02X", note the "0" which means
"pad left with zeros".

This is a wild guess as I haven't seen the code, but Michael had just this
sort of trouble yesterday night. Which also means it will get fixed very soon.

Daniel.

-- Daniel Calvelo Aros

---------- Original Message -----------
From: "Moritz Lennert" <mlennert@club.worldonline.be>
To: "Michael Barton" <michael.barton@asu.edu>
Cc: "Daniel Calvelo Aros" <dcalvelo@minag.gob.pe>, "Lorenzo Moretti"
<lorenzo.moretti@bologna.enea.it>, "Jachym Cepicky"
<jachym.cepicky@centrum.cz>, "grass devel" <grass5@grass.itc.it>
Sent: Mon, 23 May 2005 19:27:10 +0200 (CEST)
Subject: Re: [GRASS5] Updated d.vect.thematic

On Mon, May 23, 2005 19:07, Michael Barton said:
> OK,
>
> I¹ve managed to add the option to save as a GIS Manager group (Thanks go to
> Daniel for helping with parsing rgb into hex). I think this deals with most
> of the suggestions and updates that everyone made. Thanks to you all.

I get the following error when trying to load the group file (I've attached
the group file for info). Seems that the color codes are not completely
correct:

invalid color name "# 0 0FA"
invalid color name "# 0 0FA"
    (processing "-fill" option)
    invoked from within
"$leg create rectangle $x1 $y1 $x2 $y2 -outline $opt($id,color)
-fill $opt($id,fcolor)"
    (procedure "DmVector::legend" line 41) invoked from within
"DmVector::legend $id"
    (procedure "DmVector::set_option" line 7) invoked from within
"DmVector::set_option $current_node $key $val"
    ("vector" arm line 2) invoked from within "switch $type {
   group { DmGroup::set_option $current_node $key $val }
        raster { DmRaster::set_option $current_node $key $..."
    ("default" arm line 8) invoked from within "switch $key {
  Group {

      if { [regexp -- {^File (.+)} $val r leftover] && ($leftover !=
      $::Dm::filename)} {
            set val "<-- $leftover"..."
    (procedure "Dm::load" line 46)
    invoked from within
"Dm::load $::Dm::filename_new"
    (procedure "Dm::OpenFileBox" line 20)
    invoked from within
"Dm::OpenFileBox .mainframe.topf.tb1"
    ("uplevel" body line 1)
    invoked from within
"uplevel \#0 $cmd"
    (procedure "Button::_release" line 18)
    invoked from within
"Button::_release .mainframe.topf.tb1.bbox2.b1"
    (command bound to event)

------- End of Original Message -------

Daniel

I used your awk code, as it is simpler than mine. I've attached a copy here.
I'm baffled as to why Moritz is getting a bad color value.

Moritz,

Try the new code here. If it doesn't work, please take a look at the ascii
group file that d.vec.thematic is creating. Where are the color values off?
Do you have a non-GNU version of AWK?

Michael

On 5/23/05 10:40 AM, "Daniel Calvelo Aros" <dcalvelo@minag.gob.pe> wrote:

Hi Moritz,

Try to find the spots in the code having things like 'printf("#%2X%2X' in the
awk code and change each of those "%2X" to "%02X", note the "0" which means
"pad left with zeros".

This is a wild guess as I haven't seen the code, but Michael had just this
sort of trouble yesterday night. Which also means it will get fixed very soon.

Daniel.

-- Daniel Calvelo Aros

---------- Original Message -----------
From: "Moritz Lennert" <mlennert@club.worldonline.be>
To: "Michael Barton" <michael.barton@asu.edu>
Cc: "Daniel Calvelo Aros" <dcalvelo@minag.gob.pe>, "Lorenzo Moretti"
<lorenzo.moretti@bologna.enea.it>, "Jachym Cepicky"
<jachym.cepicky@centrum.cz>, "grass devel" <grass5@grass.itc.it>
Sent: Mon, 23 May 2005 19:27:10 +0200 (CEST)
Subject: Re: [GRASS5] Updated d.vect.thematic

On Mon, May 23, 2005 19:07, Michael Barton said:

OK,

I¹ve managed to add the option to save as a GIS Manager group (Thanks go to
Daniel for helping with parsing rgb into hex). I think this deals with most
of the suggestions and updates that everyone made. Thanks to you all.

I get the following error when trying to load the group file (I've attached
the group file for info). Seems that the color codes are not completely
correct:

invalid color name "# 0 0FA"
invalid color name "# 0 0FA"
    (processing "-fill" option)
    invoked from within
"$leg create rectangle $x1 $y1 $x2 $y2 -outline $opt($id,color)
-fill $opt($id,fcolor)"
    (procedure "DmVector::legend" line 41) invoked from within
"DmVector::legend $id"
    (procedure "DmVector::set_option" line 7) invoked from within
"DmVector::set_option $current_node $key $val"
    ("vector" arm line 2) invoked from within "switch $type {
   group { DmGroup::set_option $current_node $key $val }
   raster { DmRaster::set_option $current_node $key $..."
    ("default" arm line 8) invoked from within "switch $key {
  Group {

if { [regexp -- {^File (.+)} $val r leftover] && ($leftover !=
$::Dm::filename)} {
set val "<-- $leftover"..."
    (procedure "Dm::load" line 46)
    invoked from within
"Dm::load $::Dm::filename_new"
    (procedure "Dm::OpenFileBox" line 20)
    invoked from within
"Dm::OpenFileBox .mainframe.topf.tb1"
    ("uplevel" body line 1)
    invoked from within
"uplevel \#0 $cmd"
    (procedure "Button::_release" line 18)
    invoked from within
"Button::_release .mainframe.topf.tb1.bbox2.b1"
    (command bound to event)

------- End of Original Message -------

____________________
C. Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
PO Box 872402
Arizona State University
Tempe, AZ 85287-2402
USA

Phone: 480-965-6262
Fax: 480-965-7671
www: <www.public.asu.edu/~cmbarton>

(attachments)

quartile_theme.dm (2.5 KB)
d.vect.thematic (23.8 KB)

On Mon, May 23, 2005 20:40, Michael Barton said:

Daniel

I used your awk code, as it is simpler than mine. I've attached a copy here.
I'm baffled as to why Moritz is getting a bad color value.

Moritz,

Try the new code here.

The new code works !

If it doesn't work, please take a look at the ascii
group file that d.vec.thematic is creating. Where are the color values off?
Do you have a non-GNU version of AWK?

I had attached the group file to my last mail.

I am using mawk which is the default awk version on Debian. Maybe this was the
problem.

Thanks once again.

Moritz

Try to find the spots in the code having things like 'printf("#%2X%2X'
in the awk code and change each of those "%2X" to "%02X", note the "0"
which means "pad left with zeros".

yes, that's it.

COLOR=`echo "$RED:$GREEN:$BLUE" | \
   awk -F: '{printf("#%02x%02x%02x", $1, $2, $3)}'`

Note: no eval, no '\n' needed.

Hamish


GREAT WORK MICHAEL !
THANKS

OK,

I’ve managed to add the option to save as a GIS Manager group (Thanks go to Daniel for helping with parsing rgb into hex). I think this deals with most of the suggestions and updates that everyone made. Thanks to you all.

I’m at home today and don’t have access to the CVS. I’ll update this tomorrow, along with an update to the GIS Manager menu that includes the thematic mapper.

Michael

This script is an heavy enhancement for GRASS.
Now Grass can manage the thematism like other GIS software.
The group inside GIS Manager is very flexible because it permits to change any value, any color, the line, and so on and you can add the group with your raster map, commands, etc…

Mac OS X users: download last 6.1.cvs with last Michael script at:
http://wwwamb.bologna.enea.it/forgrass/downloadcvs.htm

Run grass61cvs and enter in Grass X11 terminal:
GRASS 6.1.cvs (myproject) > d.vect.thematic &
… and press enter


Possibles enhancements:

  • group name created and imported automatically inside GIS Manager without external file and with a name created “theme_vectormapname_attributecolumnname”. This is more user friendly because the user see the theme inside GIS Manager as soon as possible. If this is not good the user can delete it from GIS Manager and can recreate another thematic group from the script;
  • custom color from color palette (difficult);
  • interval from a value with a start point (eg: 20 and 0 → 0-20, 20-40, 40-60, …)
  • line color for area or no color;
  • thematism from a text value.

LEGEND
Legend now is created from the script but if you have a group with some changes that you have done after it needs a new command like (example):
d.vect.thematism.leg group_name_of_thematism monitor_number
This command look inside the the group in GIS Manager for extracting the values, the colors, the SQL query, etc… and it displays the contents in a new window.
This command can be enter inside the group name at the bottom of layer for legend.

This method for vector thematism and vector thematism legend is near to other commercial GIS software and it can be saved in a GIS Manager file.

Grass is now in a new field like thematic vector and the only lacking things is a Print management and an easy db management.

Bye and thanks for the big work.


|| Lorenzo Moretti e-mail: lorenzo.moretti@bologna.enea.it
||/|/| ENEA prot/idr Web: http://wwwamb.bologna.enea.it/
|| | via Don Fiammelli, 2 FTP: ftp://ftpamb.bologna.enea.it/ (res.)

Download GRASS for MAC OS X:
http://wwwamb.bologna.enea.it/forgrass/
________________________________________________________________________

From: Lorenzo Moretti <lorenzo.moretti@bologna.enea.it>
Sent: Tue, 24 May 2005 12:45:51 +0200

- interval from a value with a start point (eg: 20 and 0 -->0-20, 20-
40, 40-60, ...)

How about accepting a list of values from stdin as breakpoints? Something like:

$ echo 0 20 40 50 100 | d.vect.thematic -themecalc=breaks ...

That would, with some extra work, allow things like

$ db.select sql='select mycolumn from thetable' | my_classifier |
d.vect.thematic -themecalc=breaks ...

Would that be useful?

Daniel.

On Wed, May 25, 2005 6:00, Daniel Calvelo Aros said:

From: Lorenzo Moretti <lorenzo.moretti@bologna.enea.it>
Sent: Tue, 24 May 2005 12:45:51 +0200

- interval from a value with a start point (eg: 20 and 0 -->0-20, 20-
40, 40-60, ...)

How about accepting a list of values from stdin as breakpoints? Something
like:

$ echo 0 20 40 50 100 | d.vect.thematic -themecalc=breaks ...

That would, with some extra work, allow things like

$ db.select sql='select mycolumn from thetable' | my_classifier |
d.vect.thematic -themecalc=breaks ...

Would that be useful?

Yes !

Moritz

Hi Daniel

From: Lorenzo Moretti <lorenzo.moretti@bologna.enea.it>
Sent: Tue, 24 May 2005 12:45:51 +0200

- interval from a value with a start point (eg: 20 and 0 -->0-20, 20-
40, 40-60, ...)

How about accepting a list of values from stdin as breakpoints? Something like:

$ echo 0 20 40 50 100 | d.vect.thematic -themecalc=breaks ...

That would, with some extra work, allow things like

$ db.select sql='select mycolumn from thetable' | my_classifier |
d.vect.thematic -themecalc=breaks ...

Would that be useful?

Daniel.

Yes
It's more easy to start from an exact value (eg: 0) and after select the range. The user can make a first screening like now and he see all values (automatic choice) and after he inserts the custom values (custom choice) for range (eg: 0 20 30 50 100 200 300 >500...).
This is an idea

--
________________________________________________________________________
|| Lorenzo Moretti e-mail: lorenzo.moretti@bologna.enea.it ||/|/| ENEA prot/idr Web: http://wwwamb.bologna.enea.it/ || | via Don Fiammelli, 2 FTP: ftp://ftpamb.bologna.enea.it/ (ris.)
~~~~~~ 40128 BOLOGNA - ITALY Ph: +39-0516098086 Fax: +39-0516098131
________________________________________________________________________

It's more easy to start from an exact value (eg: 0) and after select
the range. The user can make a first screening like now and he see
all values (automatic choice) and after he inserts the custom values
(custom choice) for range (eg: 0 20 30 50 100 200 300 >500...).
This is an idea

d.legend has range= and use= options to do this sort of thing for raster
data. It would be nice to use the same methods for vector legends
created with other modules so that it is easier for new users to learn.

Hamish

I think someone (Jachym I think) has redone d.legend to display vector data
as well as raster data. This will hopefully address this. Once it is all
working, it might be possible to redo d.vect.thematic to use the new
d.legend rather than creating one using d.graph as I do now.

Michael
______________________________
Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262; fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Hamish <hamish_nospam@yahoo.com>
Date: Fri, 27 May 2005 18:43:58 +1200
To: Lorenzo Moretti <lorenzo.moretti@bologna.enea.it>
Cc: <michael.barton@asu.edu>, <dcalvelo@minag.gob.pe>,
<mlennert@club.worldonline.be>, <jachym.cepicky@centrum.cz>,
<grass5@grass.itc.it>
Subject: Re: [GRASS5] Updated d.vect.thematic

It's more easy to start from an exact value (eg: 0) and after select
the range. The user can make a first screening like now and he see
all values (automatic choice) and after he inserts the custom values
(custom choice) for range (eg: 0 20 30 50 100 200 300 >500...).
This is an idea

d.legend has range= and use= options to do this sort of thing for raster
data. It would be nice to use the same methods for vector legends
created with other modules so that it is easier for new users to learn.

Hamish

On Fri, May 27, 2005 at 11:40:17AM -0700, Michael Barton wrote:

I think someone (Jachym I think) has redone d.legend to display vector data
as well as raster data. This will hopefully address this. Once it is all
working, it might be possible to redo d.vect.thematic to use the new
d.legend rather than creating one using d.graph as I do now.

Michael

I did it. With the last patches, I posted, d.legend is able to work with with
vector data to. See http://article.gmane.org/gmane.comp.gis.grass.devel/7692/match=legend for details.

It would be good however, if someone could tell me, how to make d.legend to
draw icons. I copyed part of the code form d.vect, but nothing is showen. The
actual source can be found on

    http://les-ejk.cz/programs/grass/d.legend.tgz

Icons are drawed in icon.c (which could be later G_symbol(); - some time).

Any comments are welcomed

BUT, d.legend searches for new categories from the database in given column.
The legend will not look like d.vect.thematic legend looks like (e.g.):

    0.1 - 0.2
    0.2 - 0.3
    ...

but
    0.1
    0.2
    0.3
    ...

The intervales would have to be saved in database too..

Jachym

--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://les-ejk.cz/gnupg_public_key/

Hi Jachym, All

Is vector support in d.legend going to be incorporated into Grass61 CVS?
That's a very usefull feature, it would be great to make it available for
users.

Thanks for your effort Jachym!

Best,
Maciek

From: "Jachym Cepicky" <jachym.cepicky@centrum.cz>

On Fri, May 27, 2005 at 11:40:17AM -0700, Michael Barton wrote:

I think someone (Jachym I think) has redone d.legend to display vector
data
as well as raster data. This will hopefully address this. Once it is all
working, it might be possible to redo d.vect.thematic to use the new
d.legend rather than creating one using d.graph as I do now.

Michael

I did it. With the last patches, I posted, d.legend is able to work with
with
vector data to. See
http://article.gmane.org/gmane.comp.gis.grass.devel/7692/match=legend for
details.

It would be good however, if someone could tell me, how to make d.legend
to
draw icons. I copyed part of the code form d.vect, but nothing is showen.
The
actual source can be found on

   http://les-ejk.cz/programs/grass/d.legend.tgz

Icons are drawed in icon.c (which could be later G_symbol(); - some time).

Any comments are welcomed

BUT, d.legend searches for new categories from the database in given
column.
The legend will not look like d.vect.thematic legend looks like (e.g.):

   0.1 - 0.2
   0.2 - 0.3
   ...

but
   0.1
   0.2
   0.3
   ...

The intervales would have to be saved in database too..

Jachym

--------------------
W polskim Internecie sÂą setki milionĂłw stron. My przekazujemy Tobie tylko najlepsze z nich!
http://katalog.epf.pl/

Is vector support in d.legend going to be incorporated into Grass61
CVS? That's a very usefull feature, it would be great to make it
available for users.

I would like the symbol drawing code made into a library function first.

Hamish

On Mon, September 19, 2005 3:16, Hamish said:

Is vector support in d.legend going to be incorporated into Grass61
CVS? That's a very usefull feature, it would be great to make it
available for users.

I would like the symbol drawing code made into a library function first.

I just committed an option to d.vect.thematic that allows the creation of
ps.map instruction files, one for the map and one for the legend. It takes up
the symbol that is used for display.

Michael: I've also already included it into thematic.tcl for the Gis Manager.
I just copied some existing code and hope I understood the process correctly.
It seems to work for me at least.

Moritz

That's great! I think it's better than trying to save as group for what you
want to do. Have you looked at the code for transforming layers in general
to ps.map commands? Thanks very much for working on this.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Moritz Lennert <mlennert@club.worldonline.be>
Reply-To: <mlennert@club.worldonline.be>
Date: Mon, 19 Sep 2005 14:10:33 +0200 (CEST)
To: Hamish <hamish_nospam@yahoo.com>
Cc: Maciek Sieczka <werchowyna@epf.pl>, <jachym.cepicky@centrum.cz>,
<michael.barton@asu.edu>, <grass5@grass.itc.it>
Subject: ps.map file option in d.vect.thematic (was:Re: [GRASS5] Updated
d.vect.thematic)

On Mon, September 19, 2005 3:16, Hamish said:

Is vector support in d.legend going to be incorporated into Grass61
CVS? That's a very usefull feature, it would be great to make it
available for users.

I would like the symbol drawing code made into a library function first.

I just committed an option to d.vect.thematic that allows the creation of
ps.map instruction files, one for the map and one for the legend. It takes up
the symbol that is used for display.

Michael: I've also already included it into thematic.tcl for the Gis Manager.
I just copied some existing code and hope I understood the process correctly.
It seems to work for me at least.

Moritz