[GRASSLIST:3890] How to generate merge key in Grass to enable merging data in R?
Craig Aumann
caumann at ualberta.ca
Tue Jul 13 17:27:44 EDT 2004
In more detail, I have read some vector data containing lines into
GRASS:
----------------------
SHPDIR=/home/caumann/amedata/evergreen/data
DBFDIR=/home/caumann/amedata/evergreen/data
SHPFILE="seismic"
DBFFILE="seismic"
ATT=_att
ATTNAME="$SHPFILE$ATT"
echo "$SHPFILE"
echo "$DBFFILE"
v.in.ogr -o dsn="$SHPDIR" output="$SHPFILE" layer="$SHPFILE"
db.copy from_driver=dbf from_database=$DBFDIR \
from_table=$DBFFILE \
to_driver=pg to_database="dbname=alpac_netdown,user=caumann" \
to_table=$ATTNAME
v.db.connect -o map="$SHPFILE" table="$ATTNAME" key=LINK_KEY \
driver=pg database="dbname=alpac_netdown,user=caumann"
v.out.ascii input="$SHPFILE" output=seismic.txt
----------------------------
What I then do is read the text file "seismic.txt" into R and find the
center of the line. What I want to do now is link these centers to the
attribute data which is sitting in the attribute database. Reading the
attribute database into R is easy:
-----------
conn <- dbConnect(PgSQL(), dbname="alpac_netdown", user="caumann")
dbListTables(conn)
seis <- dbReadTable(conn, "seismic_att")
dbDisconnect(conn)
-----------
What I can't figure out is how to create a unique "key" in BOTH the
attribute database "seismic_att" AND in the exported shape file
"seismic.txt" so I can then link the line centers created in R to the
associated attribute information for a given line using that key.
I hope this is trivial... Its just that I can't figure it out what I
need to do on the GRASS57 side of things!
Cheers!
Craig
More information about the grass-user
mailing list