[GRASS5] r.to.pg: awk question
Markus Neteler
neteler at geog.uni-hannover.de
Tue Jul 25 08:46:36 EDT 2000
Hi again,
just now I submitted a script
r.to.pg
into CVS:
src/scripts/contrib/r.to.pg
It allows to write a GRASS raster map into a
one-column table into PostgreSQL. I use it to
analyse large datasets in "R" using the RPgSQL
library (R data proxy).
Following problem I have: Currently the table name
is static: "celltable". I would prefer the map's
name instead. But: As I use awk to generate the
INSERT statements, I have to get the table name
variable into awk. How to do this?
$1: GRASS raster map name
[...]
TABLENAME="somestring"
#get the raster values and write out SQL:
r.stats -1 nv='-9999' in=$1 | awk 'BEGIN{}
NR == 1{}
{printf "INSERT INTO %s VALUES ( %.5f);\n", $TABLENAME, $1 >> "/tmp/pgimport.sql"}
END{}'
[...]
Above printf line is not working, I can just use a hard-coded
"tablename" instead of $TABLENAME. Means: How to use environmental
variables in awk?
Thanks for any advice!
Markus
PS: The cat text is not yet supported, but would be a good idea.
----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo at geog.uni-hannover.de with
subject 'unsubscribe grass5'
More information about the grass-dev
mailing list