[GRASS5] experimental thematic maps from expressions

Daniel Calvelo Aros dcalvelo at minag.gob.pe
Fri Jun 10 05:33:27 EDT 2005


Hi *,

This is a first attempt at extending d.vect.thematic to handle expressions,
which might make several people happy. The interface to d.vect.thematic
doesn't change; just use an expression involving column names in place of a
single column in d.vect.thematic (don't forget to quote). E.g.:

d.vect.thematic my_vector column="(col1+col2)/col3"

The expressions available are simple arithmetic ones, i.e. four operations and
parentheses, involving column names and constants. This is limited by the
arithmetic capabilities of both awk and the sql parser. Anything fancier IMHO
should be provided by an extended UPDATE ... SET or a v.db.calc command.

To properly use correct arithmetic notation, the patch I just sent for the sql
parser should be applied.


The idea is the following:

a) the expression is used in computing breaks, just as in the original
d.vect.thematic; the statistics used for break calculation are obtained from a
computed value using the expression.

b) selection of the vector objects in each interval is accomplished in the
same way as for d.vect.thematic, only this time expressions and not simple
column values are used.

For a) I mostly tweaked v.univar.sh to compute the values of the expression.
This part takes also good care of the dreaded division by zero.
d.vect.thematic was only changed to use proper quoting when handling the
expression, and the numeric check for the column was delegated to v.univar.sh.

However, dbmi doesn't handle division by zero errors other than by bailing
out. So, even if breaks are calculated ignoring zero denominators, selecting
the objects for each class will abort everything in case of a zero-valued
denominator anywhere in the expression. 

Any ideas on how to deal with this?

Otherwise, comments are most welcome.

Daniel.

-- Daniel Calvelo Aros
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v.univar.sh
Type: application/octet-stream
Size: 6652 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20050610/10800341/v.univar.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d.vect.thematic
Type: application/octet-stream
Size: 24409 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20050610/10800341/d.vect.obj


More information about the grass-dev mailing list