[GRASS-user] combining and evaluating vector dbf values

Hi,

Any help in doing the following:

I have a combined vector in grass using v.overlay

I now have a dbf table with the following
a_value = integer
a_value2 = integer
b_value = string

Now I want to combine the categories in another column (c_value) like :

evaluate b_value, a_value, a_value2
then assign c_value from a lookup table

the lookup table is a set of integer values based on the various
combinations of b_value, a_value, a_value2

Any ideas doing this in GRASS or oodbase?

cheers,
maning

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

Hi,

Answering partially to my problem.

I found a way to update columns by from a criteria of another column

like this:
v.info -c overlay_trainingANDforest2002_sq
lDisplaying column types/names for database connection of layer 1:
INTEGER|cat
INTEGER|a_cat
INTEGER|a_value
CHARACTER|a_label
INTEGER|a_COVER
INTEGER|b_cat
CHARACTER|b_ID
CHARACTER|b_TYPE
INTEGER|c_COVER

v.db.update map=overlay_trainingANDforest2002_sql col=c_COVER
value=112 where="a_Cover=112

And It's really fast for 100K records! Now, how do make an sql
expression by evaluationg multiple columns?

cheers,
maning

On Tue, Nov 25, 2008 at 12:01 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Hi,

Any help in doing the following:

I have a combined vector in grass using v.overlay

I now have a dbf table with the following
a_value = integer
a_value2 = integer
b_value = string

Now I want to combine the categories in another column (c_value) like :

evaluate b_value, a_value, a_value2
then assign c_value from a lookup table

the lookup table is a set of integer values based on the various
combinations of b_value, a_value, a_value2

Any ideas doing this in GRASS or oodbase?

cheers,
maning

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

Nearly there but not quite:

The final column should combine the values from the 2 columns, am I
right that concat doesn't work with dbf?

So this doesn't work
echo "UPDATE vectormap SET c_COVER = a_COVER || a_value" | db.execute

cheers,
maning
On Tue, Nov 25, 2008 at 2:34 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Hi,

Answering partially to my problem.

I found a way to update columns by from a criteria of another column

like this:
v.info -c overlay_trainingANDforest2002_sq
lDisplaying column types/names for database connection of layer 1:
INTEGER|cat
INTEGER|a_cat
INTEGER|a_value
CHARACTER|a_label
INTEGER|a_COVER
INTEGER|b_cat
CHARACTER|b_ID
CHARACTER|b_TYPE
INTEGER|c_COVER

v.db.update map=overlay_trainingANDforest2002_sql col=c_COVER
value=112 where="a_Cover=112

And It's really fast for 100K records! Now, how do make an sql
expression by evaluationg multiple columns?

cheers,
maning

On Tue, Nov 25, 2008 at 12:01 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Hi,

Any help in doing the following:

I have a combined vector in grass using v.overlay

I now have a dbf table with the following
a_value = integer
a_value2 = integer
b_value = string

Now I want to combine the categories in another column (c_value) like :

evaluate b_value, a_value, a_value2
then assign c_value from a lookup table

the lookup table is a set of integer values based on the various
combinations of b_value, a_value, a_value2

Any ideas doing this in GRASS or oodbase?

cheers,
maning

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

After struggling with this without any solution for the past 2 dyas.
I will try r.cross

On Tue, Nov 25, 2008 at 4:07 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Nearly there but not quite:

The final column should combine the values from the 2 columns, am I
right that concat doesn't work with dbf?

So this doesn't work
echo "UPDATE vectormap SET c_COVER = a_COVER || a_value" | db.execute

cheers,
maning
On Tue, Nov 25, 2008 at 2:34 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Hi,

Answering partially to my problem.

I found a way to update columns by from a criteria of another column

like this:
v.info -c overlay_trainingANDforest2002_sq
lDisplaying column types/names for database connection of layer 1:
INTEGER|cat
INTEGER|a_cat
INTEGER|a_value
CHARACTER|a_label
INTEGER|a_COVER
INTEGER|b_cat
CHARACTER|b_ID
CHARACTER|b_TYPE
INTEGER|c_COVER

v.db.update map=overlay_trainingANDforest2002_sql col=c_COVER
value=112 where="a_Cover=112

And It's really fast for 100K records! Now, how do make an sql
expression by evaluationg multiple columns?

cheers,
maning

On Tue, Nov 25, 2008 at 12:01 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Hi,

Any help in doing the following:

I have a combined vector in grass using v.overlay

I now have a dbf table with the following
a_value = integer
a_value2 = integer
b_value = string

Now I want to combine the categories in another column (c_value) like :

evaluate b_value, a_value, a_value2
then assign c_value from a lookup table

the lookup table is a set of integer values based on the various
combinations of b_value, a_value, a_value2

Any ideas doing this in GRASS or oodbase?

cheers,
maning

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

On Tue, Nov 25, 2008 at 9:07 AM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Nearly there but not quite:

The final column should combine the values from the 2 columns, am I
right that concat doesn't work with dbf?

So this doesn't work
echo "UPDATE vectormap SET c_COVER = a_COVER || a_value" | db.execute

Did you try the SQLite driver?

Just create a new mapset, define the connection with "db.connect" (see manual
for copy-paste command) and "g.copy" the map from the DBF mapset
into the sqlite mapset.
Then the joys of SQL are available.

Markus

Geez!!! 2 days of banging my head I just did with sqlite databrowser
in 15 minutes (including create new mapset, download install sqlite,
and run concat to the database)
Thanks again! And sqlite will be my default db driver for now.

cheers,
maning

On Wed, Nov 26, 2008 at 6:12 PM, Markus Neteler <neteler@osgeo.org> wrote:

On Wed, Nov 26, 2008 at 10:45 AM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Thanks for bringing some light into this dark FOSS GIS moments.

:slight_smile:
Note that SQLite is the default driver in GRASS 7, so those dark moments
shouldn't happen any more in future (mhh, maybe there will be others...).

Markus

On Wed, Nov 26, 2008 at 5:42 PM, Markus Neteler <neteler@osgeo.org> wrote:

On Wed, Nov 26, 2008 at 10:40 AM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

So, it's really a limitation inherent to the dbf driver?

Yes. DBF != SQL... we hacked in a couple of SQL statements but not entire SQL92.

I guess sqlite it is. Is it possible to g.copy again the vector from the
sqlite Mapset to the dbf Mapset?

Sure!

Best
Markus

cheers,
maning

On Wed, Nov 26, 2008 at 5:36 PM, Markus Neteler <neteler@osgeo.org> wrote:

On Tue, Nov 25, 2008 at 9:07 AM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Nearly there but not quite:

The final column should combine the values from the 2 columns, am I
right that concat doesn't work with dbf?

So this doesn't work
echo "UPDATE vectormap SET c_COVER = a_COVER || a_value" | db.execute

Did you try the SQLite driver?

Just create a new mapset, define the connection with "db.connect" (see manual
for copy-paste command) and "g.copy" the map from the DBF mapset
into the sqlite mapset.
Then the joys of SQL are available.

Markus

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

--
Open Source Geospatial Foundation
http://www.osgeo.org/
http://www.grassbook.org/

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|

--
Open Source Geospatial Foundation
http://www.osgeo.org/
http://www.grassbook.org/

--
|---------|----------------------------------------------------------|
| __.-._ |"Ohhh. Great warrior. Wars not make one great." -Yoda |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
| /'.-c |Linux registered user #402901, http://counter.li.org/ |
| | /T |http://esambale.wikispaces.com/ |
| _)_/L I http://epsg4253.wordpress.com/ |
|---------|----------------------------------------------------------|