[GRASS-user] displaying points based on attributes

Hi,

I have imported a shape file containing simple points, with an associated
attribute table. I can see the attribute table in the 'dbf' directory of
the mapset. When working from the display manager, however, I cannot find
how to vary symbols/colors for the points, based on an attribute of
choice. Can somebody please point out how this is done? Thanks in
advance.

Cheers,

--
Seb

Seb wrote:

I have imported a shape file containing simple points, with an
associated attribute table. I can see the attribute table in the
'dbf' directory of the mapset. When working from the display manager,
however, I cannot find how to vary symbols/colors for the points,
based on an attribute of choice. Can somebody please point out how
this is done? Thanks in advance.

by category:

add the vector map multiple times, one for each symbol/color
combination, and then restrict with "use SQL query" box.
e.g. "ATTRIBUTE > 6" or "ATTRIBUTE = 'large'" See the SQL help
pages for syntax.

graduated by value:

d.vect.thematic (Add thematic map layer button next to add vector
button)

Hamish

Hamish wrote:

Seb wrote:

I have imported a shape file containing simple points, with an
associated attribute table. I can see the attribute table in the
'dbf' directory of the mapset. When working from the display manager,
however, I cannot find how to vary symbols/colors for the points,
based on an attribute of choice. Can somebody please point out how
this is done? Thanks in advance.

by category:

add the vector map multiple times, one for each symbol/color
combination, and then restrict with "use SQL query" box.
e.g. "ATTRIBUTE > 6" or "ATTRIBUTE = 'large'" See the SQL help
pages for syntax.

graduated by value:

d.vect.thematic (Add thematic map layer button next to add vector
button)

You can also use a grassrgb column in your dbf file, in which you give an rgb color value (in the form 154:265:247) in each line. You can do this with v.db.addcol and v.db.update (accessible in GIS Manager via Databases->Manage Databases). This color then serves as _fillcolor_ (not outline !), so you have to chose a point icon which can be filled (e.g. circle, box, etc):

v.db.addcol map=YourMap columns="grassrgb varchar(11)" # create grassrgb column

v.db.update map=YourMap column=grassrgb value="'255:0:0'" where="attribute=X" # update grassrgb with color red where attribute is equal to X (watch out for quoting of color value: single quotes in double quotes on command line, single quotes in GUI
or
v.db.update map=YourMap column=grassrgb value="'255:0:0'" where="attribute>X and attribute <= Y" # update grassrgb with color red where attribute is between X and Y

Then to display your points:

d.vect -a map=YourMap etc...

A while ago, Martin Landa also said that he might try to implement random colors for any attribute column (instead of only category value): http://grass.itc.it/pipermail/grass5/2006-June/023516.html
CC'ing him to see if he ever got around to it. This would allow you to use d.vect -c

The biggest problem I see with all this at this stage in GRASS, is that with the exception of d.vect.thematic, you cannot easily get a legend for the colors used...

Moritz

On Wed, 11 Oct 2006 10:12:11 +0200,
Moritz Lennert <mlennert@club.worldonline.be> wrote:

[...]

You can also use a grassrgb column in your dbf file, in which you give an
rgb color value (in the form 154:265:247) in each line. You can do this
with v.db.addcol and v.db.update (accessible in GIS Manager via
Databases->Manage Databases). This color then serves as _fillcolor_ (not
outline !), so you have to chose a point icon which can be filled
(e.g. circle, box, etc):

[...]

Thanks for these ideas Martin. It seems as I would have to update to the
development version to use these though, as none of these functions are
available in my Debian testing version (corresponding to GRASS 6.0.2). An
off-list exchange showed me that other very handy options (like
copying/pasting objects in the GUI) is not available in my version. I
also heard it's possible to obtain development GRASS Debian versions, so I
may try that route. Thank you all.

Cheers,

--
Seb

Hi,

I found an alternative way to do this with my current GRASS version by
using v.reclass. However, when I try to display the new vector with
"d.vect -c icon=basic/circle [...]", the icon is not filled with random
colors as the -c flag implies, but all points are filled with the default
gray color. Any tips on what might be wrong?

Cheers,

--
Seb

Moritz Lennert wrote:

The biggest problem I see with all this at this stage in GRASS, is
that with the exception of d.vect.thematic, you cannot easily get a
legend for the colors used...

for the repeated vector map with different SQL query method, the vlegend
command in ps.map works well.

Hamish

Sebastian P. Luque wrote:

Hi,

I found an alternative way to do this with my current GRASS version by
using v.reclass. However, when I try to display the new vector with
"d.vect -c icon=basic/circle [...]", the icon is not filled with random
colors as the -c flag implies, but all points are filled with the default
gray color. Any tips on what might be wrong?

What was the exact reclass command you used ?
Are you sure the points have a category number ?

For me d.vect -c icon=basic/circle works.

Moritz

Hi all,

A while ago, Martin Landa also said that he might try to implement
random colors for any attribute column (instead of only category value):
http://grass.itc.it/pipermail/grass5/2006-June/023516.html
CC'ing him to see if he ever got around to it. This would allow you to
use d.vect -c

partly forgot;-), still in my TODO. I will try to implement it as soon
as possible...

Best regards, Martin

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

I've learned that in GRASS, it helps to think raster. Try the following:

1. Make a raster version of your vector data (or even make a simple
schematic raster map that simply has one or more grid cells for each
category in your vector map)
2. Use r.colors with rules to color the rasterized points (or any other
feature) based on an attribute that you save with your raster to match the
colors you use in the color column for vectors
3. Display your colored vector map
4. Use d.legend to display a nice legend for the raster version of your
vector map
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

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

From: Hamish <hamish_nospam@yahoo.com>
Date: Thu, 12 Oct 2006 16:10:40 +1300
To: Moritz Lennert <mlennert@club.worldonline.be>
Cc: <grassuser@grass.itc.it>, <spluque@gmail.com>
Subject: Re: [GRASS-user] displaying points based on attributes

Moritz Lennert wrote:

The biggest problem I see with all this at this stage in GRASS, is
that with the exception of d.vect.thematic, you cannot easily get a
legend for the colors used...

for the repeated vector map with different SQL query method, the vlegend
command in ps.map works well.

Hamish