[GRASS-user] exponentiation with v.db.update

Hi,
I'm trying to populate a column with 10 raised to the power of the
values in another column:

v.db.update map=ItaReg column=x qcolumn=10^logx

but I get a dbmi protocol error. I've tried using either single or
double quotes with no success. If I use a combination of both, i.e.
"qcolumn= ' 10^logx ' " it doesn't report any error, but doesn't do
the operation either (the column remains unchanged).

It works fine for other operations (e.g. 10*logx), though. Is there
another way in which I should specify the exponentiation?

Thanks,
Marcia

Hi,

Which database back-end are you using? I seem to recall that the DBF
back-end only supports a very limited subset of update operations.

cheers,
Dylan

On Tue, Jun 9, 2009 at 8:56 AM, A. Marcia
BARBOSA<anamarciabarbosa@gmail.com> wrote:

Hi,
I'm trying to populate a column with 10 raised to the power of the
values in another column:

v.db.update map=ItaReg column=x qcolumn=10^logx

but I get a dbmi protocol error. I've tried using either single or
double quotes with no success. If I use a combination of both, i.e.
"qcolumn= ' 10^logx ' " it doesn't report any error, but doesn't do
the operation either (the column remains unchanged).

It works fine for other operations (e.g. 10*logx), though. Is there
another way in which I should specify the exponentiation?

Thanks,
Marcia
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

On 09/06/09 17:56, A. Marcia BARBOSA wrote:

Hi,
I'm trying to populate a column with 10 raised to the power of the
values in another column:

v.db.update map=ItaReg column=x qcolumn=10^logx

but I get a dbmi protocol error. I've tried using either single or
double quotes with no success. If I use a combination of both, i.e.
"qcolumn= ' 10^logx ' " it doesn't report any error, but doesn't do
the operation either (the column remains unchanged).

It works fine for other operations (e.g. 10*logx), though. Is there
another way in which I should specify the exponentiation?

Which db backend are you using ?

This works for me with a PostgreSQL database:

v.db.addcol ssbel_pg col="test double precision"
v.db.update ssbel_pg col=test value="cat^2" (or qcol="cat^2")

In PostgreSQL there is also power(a,b).

For SQLite the same function is available in the extension-functions.c available here:
http://sqlite.org/contrib/download/

Moritz

Yeah I'm doing it on a dbf attribute table. It doesn't work with the
quotes, nor with power(10,x) - error message always.
Does anyone know how to do an exponentiation update on a dbf table? Or
do I really have to do the update outside GRASS and then re-connect
the table?

Cheers,
Márcia

A. Marcia BARBOSA ha scritto:

do I really have to do the update outside GRASS and then re-connect
the table?

why not using sqlite backend? dbf is very limited for any serious use.
--
Paolo Cavallini: http://www.faunalia.it/pc

why not using sqlite backend? dbf is very limited for any serious use.

It may seem quite simple for some, but to me all these things are a
complete mystery... I'm actually very surprised I became able to
handle GRASS! I'm planning on switching all my databases to PostgreSQL
within this year (after taking a course, of course), but right now I
have to work with what I've got... dbf it is. I've just managed to
calculate the column outside and re-connect it to the vector map.

Grazie,
Márcia

On Tuesday 09 June 2009, A. Marcia BARBOSA wrote:

> why not using sqlite backend? dbf is very limited for any serious use.

It may seem quite simple for some, but to me all these things are a
complete mystery... I'm actually very surprised I became able to
handle GRASS! I'm planning on switching all my databases to PostgreSQL
within this year (after taking a course, of course), but right now I
have to work with what I've got... dbf it is. I've just managed to
calculate the column outside and re-connect it to the vector map.

Well, when you get a chance, here are some tips on converting DB back-ends:
http://casoilresource.lawr.ucdavis.edu/drupal/node/733

Note that there is a lot of red text on that page. It means "be careful!".

Cheers,
Dylan

--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

A. Marcia BARBOSA ha scritto:

why not using sqlite backend? dbf is very limited for any serious use.

It may seem quite simple for some, but to me all these things are a
complete mystery... I'm actually very surprised I became able to
handle GRASS! I'm planning on switching all my databases to PostgreSQL
within this year (after taking a course, of course)

It is not so bad:
http://grass.itc.it/grass64/manuals/html64_user/databaseintro.html

To migrate a GRASS database table (or a GRASS vector map) to a different
DBMI engine, the best solution is to create a new MAPSET, define the
DBMI settings accordingly with db.connect and if needed, db.login. Then
the table of interest can be copied over with db.copy from the original
MAPSET. Likewise, a vector map including its table(s) are copied from
the original MAPSET to the current MAPSET with g.copy.

PostgreSQL might be overkill for personal use.
All the best.
--
Paolo Cavallini: http://www.faunalia.it/pc

On 09/06/09 18:38, A. Marcia BARBOSA wrote:

Yeah I'm doing it on a dbf attribute table. It doesn't work with the
quotes, nor with power(10,x) - error message always.
Does anyone know how to do an exponentiation update on a dbf table? Or
do I really have to do the update outside GRASS and then re-connect
the table?

SQL for dbf is very limited [1,2], so you would have to either do it outside GRASS, or switch to a more sophisticated SQL backend.

Moritz

[1]http://grass.osgeo.org/grass64/manuals/html64_user/sql.html
[2]http://grass.osgeo.org/grass64/manuals/html64_user/grass-dbf.html