[GRASS5] [bug #3277] (grass) d.vect.thematic fails with DOUBLE

In Grass CVS 30.05.2005 d.vect.thematic still doesn't accept the DOUBLE data
but the error information is different:

d.vect.thematic map=gminy_zw_2003_prc_dem@admin type=centroid column=PROD
'themetype=graduated points' themecalc=interval layer=1 icon=basic/circle
size=5 maxsize=20 nint=4 colorscheme=blue-red singlecolor=0:250:0
startcolor=250:0:0 endcolor=0:0:250 monitor=x2 -l

ERROR: Column <PROD> is of type <double precision
double precision> which is not numeric.

Double precision is not numeric? (I'm only a simple user.)

Maciek

-------------------------------------------- Managed by Request Tracker

In Grass CVS 30.05.2005 d.vect.thematic still doesn't accept the
DOUBLE data but the error information is different:

d.vect.thematic map=gminy_zw_2003_prc_dem@admin type=centroid
column=PROD 'themetype=graduated points' themecalc=interval layer=1
icon=basic/circle size=5 maxsize=20 nint=4 colorscheme=blue-red
singlecolor=0:250:0 startcolor=250:0:0 endcolor=0:0:250 monitor=x2 -l

ERROR: Column <PROD> is of type <double precision
double precision> which is not numeric.

Double precision is not numeric? (I'm only a simple user.)

note the type is:

<double precision
double precision>

I think the problem is thus:

# check column type
COLTYPE="`v.info -c $GIS_OPT_map [...] | grep $GIS_OPT_column | [...]

If you have a column PROD and another column with "PROD" in it, e.g.
PROD2, the grep step will pick out both.

Try using the regex start of line and end of line markers to refine the
search:

... | grep ^"$GIS_OPT_column"$ | ...

Hamish

Hamish <hamish_nospam <at> yahoo.com> writes:

> Grass CVS 30.05.2005 d.vect.thematic
> ...
> ERROR: Column <PROD> is of type <double precision
> double precision> which is not numeric.
>
> Double precision is not numeric? (I'm only a simple user.)

note the type is:

<double precision
double precision>

I think the problem is thus:

# check column type
COLTYPE="`v.info -c $GIS_OPT_map [...] | grep $GIS_OPT_column | [...]

If you have a column PROD and another column with "PROD" in it, e.g.
PROD2, the grep step will pick out both.

Try using the regex start of line and end of line markers to refine the
search:

... | grep ^"$GIS_OPT_column"$ | ...

Hamish

Hamish

Your proposition didn't do it but after one hour of tough reading

^'[$GIS_OPT_column]'

did. Though I still don't know how.

Thanks for making me to dig bash a bit. If this solution is ok please apply it,
I'm not allowed to write to CVS, thanks god :).

Maciek

From: Maciek Sieczka <werchowyna@epf.pl>
Sent: Tue, 31 May 2005 10:19:49 +0000 (UTC)

Hamish <hamish_nospam <at> yahoo.com> writes:
>
> # check column type
> COLTYPE="`v.info -c $GIS_OPT_map [...] | grep $GIS_OPT_column | [...]
>
> If you have a column PROD and another column with "PROD" in it, e.g.
> PROD2, the grep step will pick out both.
>
> Try using the regex start of line and end of line markers to refine the
> search:
>
> ... | grep ^"$GIS_OPT_column"$ | ...

Your proposition didn't do it but after one hour of tough reading

^'[$GIS_OPT_column]'

did. Though I still don't know how.

It shouldn't have. That regexp should match a line containing any of the
characters 'G','I',... or the end of line. Could you put a debugging line
after COLTYPE=... like

v.info -c $GIS_OPT_map [...] | grep $GIS_OPT_column | awk '{print "["$0"]"}'

and post back the result of that?

Daniel

I could add the regex line markers, but have no idea how I can test this in the situation Maciek reports. How do you get a column??? Maybe someone else could add these and test it for me???

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: Mon, 30 May 2005 17:08:06 -0700
To: Maciek Sieczka via RT grass-bugs@intevation.de
Cc: grass5@grass.itc.it, Michael Barton Michael.Barton@asu.edu
Subject: Re: [GRASS5] [bug #3277] (grass) d.vect.thematic fails with DOUBLE

In Grass CVS 30.05.2005 d.vect.thematic still doesn’t accept the
DOUBLE data but the error information is different:

d.vect.thematic map=gminy_zw_2003_prc_dem@admin type=centroid
column=PROD ‘themetype=graduated points’ themecalc=interval layer=1
icon=basic/circle size=5 maxsize=20 nint=4 colorscheme=blue-red
singlecolor=0:250:0 startcolor=250:0:0 endcolor=0:0:250 monitor=x2 -l

ERROR: Column is of type which is not numeric.

Double precision is not numeric? (I’m only a simple user.)

note the type is:

I think the problem is thus:

check column type

COLTYPE="`v.info -c $GIS_OPT_map […] | grep $GIS_OPT_column | […]

If you have a column PROD and another column with “PROD” in it, e.g.
PROD2, the grep step will pick out both.

Try using the regex start of line and end of line markers to refine the
search:

… | grep ^“$GIS_OPT_column”$ | …

Hamish

From: "Daniel Calvelo Aros" <dcalvelo@minag.gob.pe>

From: Maciek Sieczka <werchowyna@epf.pl>
Sent: Tue, 31 May 2005 10:19:49 +0000 (UTC)

Hamish <hamish_nospam <at> yahoo.com> writes:
>
> # check column type
> COLTYPE="`v.info -c $GIS_OPT_map [...] | grep $GIS_OPT_column | [...]
>
> If you have a column PROD and another column with "PROD" in it, e.g.
> PROD2, the grep step will pick out both.
>
> Try using the regex start of line and end of line markers to refine the
> search:
>
> ... | grep ^"$GIS_OPT_column"$ | ...

Your proposition didn't do it but after one hour of tough reading

^'[$GIS_OPT_column]'

did. Though I still don't know how.

It shouldn't have. That regexp should match a line containing any of the
characters 'G','I',... or the end of line. Could you put a debugging line
after COLTYPE=... like

v.info -c $GIS_OPT_map [...] | grep $GIS_OPT_column | awk '{print
"["$0"]"}'

and post back the result of that?

Daniel

Gentlemen

My first "solution" really shouldn't work like you said Daniel and worked
only in this particular case.

I think I understood the problem (for real this time) and resolved it.

I have two DOUBLE PRECISSION columns, one is called PROD, the other POPROD.

Hamish's solution ... | grep ^"$GIS_OPT_column"$ | ... couldn't handle that
due to "|" between the column type and column name printed by "v.info -c",
e.g. DOUBLE PRECISION|PROD.

In this situation we need either

... | grep "|"$GIS_OPT_column$ | ...

or

... | grep -w $GIS_OPT_column | ...

Both work. Which one is better? "grep -w" seems cleaner.

One thing more: there should be another error check for "no such column"
prior to "# check column type". Let me suggest:

---
# check if the column exists
COLCHECK="`v.info -c $GIS_OPT_map layer=1 2> /dev/null | grep -w
$GIS_OPT_column

if [ "$COLCHECK" = "$GIS_OPT_column" ]; then
    echo ""
else
    echo "ERROR: No such column \""$GIS_OPT_column"\""
    exit 1
fi
---

What do you think?

Cheers,
Maciek

P.S.
This lesson I enjoyed.

> I could add the regex line markers, but have no idea how I can test
> this in the situation Maciek reports. How do you get a <double
> precision double precision> column??? Maybe someone else could add
> these and test it for me???

..

If you have a column PROD and another column with "PROD" in it, e.g.
PROD2, the grep step will pick out both.

Hamish

My first "solution" really shouldn't work like you said Daniel and
worked only in this particular case.

I think I understood the problem (for real this time) and resolved it.

I have two DOUBLE PRECISSION columns, one is called PROD, the other
POPROD.

Hamish's solution ... | grep ^"$GIS_OPT_column"$ | ... couldn't handle
that due to "|" between the column type and column name printed by
"v.info -c", e.g. DOUBLE PRECISION|PROD.

right. I was getting confused with the output of db.columns.

In this situation we need either

... | grep "|"$GIS_OPT_column$ | ...

or

... | grep -w $GIS_OPT_column | ...

Both work. Which one is better? "grep -w" seems cleaner.

I agree.

One thing more: there should be another error check for "no such
column" prior to "# check column type". Let me suggest:

---
# check if the column exists
COLCHECK="`v.info -c $GIS_OPT_map layer=1 2> /dev/null | grep -w
$GIS_OPT_column

if [ "$COLCHECK" = "$GIS_OPT_column" ]; then
    echo ""
else
    echo "ERROR: No such column \""$GIS_OPT_column"\""
    exit 1
fi
---

What do you think?

why not just:

COLTYPE=...
if [ -z "$COLTYPE" ] ; then
   echo "ERROR: No such column [$GIS_OPT_column]"
   exit 1
fi

Hamish

I get it. The second column (PROD2) has the sequence of characters "PROD" in
it.

Thanks
Michael

On 5/31/05 5:23 PM, "Hamish" <hamish_nospam@yahoo.com> wrote:

I could add the regex line markers, but have no idea how I can test
this in the situation Maciek reports. How do you get a <double
precision double precision> column??? Maybe someone else could add
these and test it for me???

..

If you have a column PROD and another column with "PROD" in it, e.g.
PROD2, the grep step will pick out both.

Hamish

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

Maciek et al.

I just committed these fixes to d.vect.thematic to the cvs:

1. changed column type check. I made 2 columns, area and area2, to test. It
tested them both correctly.

2. added a check for the existence of a column

3. I changed the documentation a bit to make it better explain how thematic
mapping works in the script.

I did not change the column test if clause to the simpler version. Markus
had suggested something similar. However, neither work correctly. They
incorrectly flag double precision and integer columns. Something about the
syntax is not quite right. The slightly more complicated way I have it
works, so I've left it alone.

Thanks for all your input.

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: Maciek Sieczka <werchowyna@epf.pl>
Date: Tue, 31 May 2005 23:29:15 +0200
To: <daniel.calvelo@minag.gob.pe>, grass devel <grass5@grass.itc.it>
Cc: <michael.barton@asu.edu>, <hamish_nospam@yahoo.com>
Subject: Re: [GRASS5] Re: [bug #3277] (grass) d.vect.thematic fails with
DOUBLE

From: "Daniel Calvelo Aros" <dcalvelo@minag.gob.pe>

From: Maciek Sieczka <werchowyna@epf.pl>
Sent: Tue, 31 May 2005 10:19:49 +0000 (UTC)

Hamish <hamish_nospam <at> yahoo.com> writes:

# check column type
COLTYPE="`v.info -c $GIS_OPT_map [...] | grep $GIS_OPT_column | [...]

If you have a column PROD and another column with "PROD" in it, e.g.
PROD2, the grep step will pick out both.

Try using the regex start of line and end of line markers to refine the
search:

... | grep ^"$GIS_OPT_column"$ | ...

Your proposition didn't do it but after one hour of tough reading

^'[$GIS_OPT_column]'

did. Though I still don't know how.

It shouldn't have. That regexp should match a line containing any of the
characters 'G','I',... or the end of line. Could you put a debugging line
after COLTYPE=... like

v.info -c $GIS_OPT_map [...] | grep $GIS_OPT_column | awk '{print
"["$0"]"}'

and post back the result of that?

Daniel

Gentlemen

My first "solution" really shouldn't work like you said Daniel and worked
only in this particular case.

I think I understood the problem (for real this time) and resolved it.

I have two DOUBLE PRECISSION columns, one is called PROD, the other POPROD.

Hamish's solution ... | grep ^"$GIS_OPT_column"$ | ... couldn't handle that
due to "|" between the column type and column name printed by "v.info -c",
e.g. DOUBLE PRECISION|PROD.

In this situation we need either

... | grep "|"$GIS_OPT_column$ | ...

or

... | grep -w $GIS_OPT_column | ...

Both work. Which one is better? "grep -w" seems cleaner.

One thing more: there should be another error check for "no such column"
prior to "# check column type". Let me suggest:

---
# check if the column exists
COLCHECK="`v.info -c $GIS_OPT_map layer=1 2> /dev/null | grep -w
$GIS_OPT_column

if [ "$COLCHECK" = "$GIS_OPT_column" ]; then
    echo ""
else
    echo "ERROR: No such column \""$GIS_OPT_column"\""
    exit 1
fi
---

What do you think?

Cheers,
Maciek

P.S.
This lesson I enjoyed.