[GRASSLIST:3908] Re: How to generate merge key in Grass to enable
merging data in R?
Craig Aumann
caumann at ualberta.ca
Wed Jul 14 13:12:52 EDT 2004
On Wed, 2004-07-14 at 01:55, Radim Blazek wrote:
> On Tuesday 13 July 2004 23:27, Craig Aumann wrote:
> > 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:
>
> You can generate centers with v.segment (calculate length/2 first).
>
> Radim
I don't think I completely I understand your approach here. Why do you
want length/2 and secondly, how would one calculate/get at this? I
suspect under your approach I'd also need either the begining or ending
vertex for the vector...
Given that I didn't see how to do the above, I started playing around
with v.extract. Given the centroid, I should be able to add this to the
attribute table with v.to.db after some more futzing.
---------------------------------
SHPFILE="seismic"
DBFFILE="seismic"
ATT=_att
ATTNAME="$SHPFILE$ATT"
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=OID \
driver=pg database="dbname=alpac_netdown,user=caumann"
v.extract input=seismic output=seismiccenter type=centroid field=1
where="(width >= '0')"
-----------------------
I (incorrectly??) thought that v.extract would extract the centroid of
the line. The output of v.extract above is distressing:
----------
GRASS 5.7.-cvs:~/grassalpac > v.extract input=seismic
output=seismiccenter type=centroid field=1 where="(width >= '0')"
WARNING: Vector 'seismiccenter' already exists and will be overwritten.
WARNING: coor files of vector 'seismiccenter at caumann' is larger than it
should be (14 bytes excess).
WARNING: Table 'seismiccenter' linked to vector did not exist.
Load cats from the database (table = seismic_att, db =
dbname=alpac_netdown,user=caumann).
147488 cats loaded from the database
ERROR: Column 'OID' not found
---------------
Why is OID not found?? Its my link key (see above). Have I screwed
something up here?
When I modify v.extract to (added "new=-1") :
-------------------
v.extract input=seismic output=seismiccenter type=centroid field=1
new=-1 where="(width >= 0)"
WARNING: Vector 'seismiccenter' already exists and will be overwritten.
Load cats from the database (table = seismic_att, db =
dbname=alpac_netdown,user=caumann).
147488 cats loaded from the database
0 primitives registered
0 areas built
0 isles built
Number of nodes : 0
Number of primitives: 0
Number of points : 0
Number of lines : 0
Number of boundaries: 0
Number of centroids : 0
Number of areas : 0
Number of isles : 0
Extracted vector map <seismiccenter> has been created.
---------------
I end up with an empty vector map!
More information about the grass-user
mailing list