[GRASS-user] v.colors usage

Rich Shepard rshepard at appl-ecosys.com
Tue Nov 6 14:57:18 PST 2018


On Tue, 6 Nov 2018, Markus Metz wrote:

> Apparently the table (not the vector map) stations exists twice: once in
> the sqlite database, once in the pg willamette-river-hg database. This is
> the reason for the confusion. A vector map can have a table that is not in
> the default database as reported by db.connect -p.

Markus M,

   I did not realize this. I thought that using db.connect with the pg driver
would use that table exclusively. This is good to know.

> db.connect as well as other db.* commands use the default database
> connection reported by db.connect -p unless specified, e.g.

   Well, it didn't here when I tried using the v.colors command. :-(

> You have to change the database connection for a given vector map with
> v.db.connect. To be safe (avoiding confusion) you might use v.db.droptable
> first. Make sure you transfer attribute values first, e.g. with db.copy.

   I had used db.copy to copy all the stations map tables to postgres except
for the stations table because that existed first in the postgres database,
and attributes there were expoorted and used with v.in.ascii to create the
grass map.

   Changing the database connection to the sqlite default I thought the
stations table was deleted:

> db.droptable -f driver=sqlite table=stations
Forcing ...
WARNING: Deleting table <stations> which is attached to following map(s):
WARNING: stations at mercury

but,

> db.connect driver=pg database="willamette-river-hg"
GRASS 7.7.svn (willamette_basin):~/data/grassdata/willamette_basin > db.connect -p
driver: pg
database: willamette-river-hg

> v.colors -c map=stations use=attr column=howmany rules=rules.txt rgb_col=bin_col --o
DBMI-SQLite driver error:
Error in sqlite3_prepare(): select * from stations where oid < 0
no such table: stations

DBMI-SQLite driver error:
Error in sqlite3_prepare(): select * from stations where oid < 0
no such table: stations

ERROR: Column <howmany> not found in table <stations>

> db.connect -p driver: pg database: willamette-river-hg schema: group:
GRASS 7.7.svn (willamette_basin):~/data/grassdata/willamette_basin

> v.db.connect map=stations -p Vector map <stations> is connected by: layer
<1/stations> table <stations> in database
</home/rshepard/data/grassdata/willamette_basin/mercury/sqlite/sqlite.db>
through driver <sqlite> with key <cat>

   So, grass tells me it dropped the sqlite database table, but it still
looks for it when I run v.colors. I suppose I need to manually change the
database type.

Regards,

Rich


More information about the grass-user mailing list