Maciej,
"Maciej" == Maciej Sieczka <tutey@o2.pl> writes:
Maciej> grass-dev@grass.itc.it wrote:
>> v.what.rast does what I need, but only with nearest
>> neighbor sampling. I could use v.sample, but that
>> creates a new map/table, and the only way to get the
>> attribute back to the original map is to use an SQL join,
Maciej> William,
Maciej> For a workaround, you can also link the output vector's
Maciej> datatable to another layer in the input vector; sth like:
Maciej> $ v.sample -b input=pts_in col=value out=pts_out rast=xxx
Maciej> $ v.db.connect map=pts_in driver=dbf table=pts_out layer=2
This is a very good idea. I will start doing this.
Maciej> BTW - anybody knows how to just copy a column from table to
Maciej> table? Or update an existing column in one column with the
Maciej> content of a column in another table? That's be the easiest
Maciej> workaround.
What I usually end up doing is temporarily connecting to a Postgres
database, for which this statement works (in your example):
UPDATE pts_in SET value = pts_out.rast_val
FROM pts_out
WHERE pts_in.cat = pts_out.cat;
However, I try to avoid keeping attributes in Postgres because I
access by GRASS databases from a variety of computers, some of which
do not have access to the Postgres server.
>> which is unsupported in dbf and sqlite databases.
Maciej> SQLite supports JOIN AFAICT. Does it fail in GRASS? Can you
Maciej> provide a test case?
The documentation says it's supported, and I have only been able to do
joins with SELECT, but not UPDATE. The way I read the SQLite
documentation, I should be able to do this:
UPDATE pts_in SET value = pts_out.rast_val WHERE pts_in.cat = pts_out.cat;
(sqlite does not allow a FROM clause in UPDATE). But I've never
gotten that to work. I worked up a little example for which I've
attached the output. I was working with today's CVS and on Mac OS X.
>> Furthermore, IMHO, v.rast.what should,
>> through options, do whatever v.sample does and v.sample
>> should be be eliminated.
Maciej> I have added the suggestion to GRASS 7 ideas on WIKI.
Thanks.
Maciej> Maciek
Bill
--
Bill Perkins
Pacific Northwest National Laboratory
Environmental Technologies Division, Hydrology Group
P.O. Box 999 MSIN K9-36
Richland, Washington, USA 99352
voice: (509) 372-6131 fax: (509) 372-6089 email: william.perkins@pnl.gov
(attachments)
sqlite_update.txt (1.99 KB)