Hi Paolo, I have tried your script:
On Tue, Jan 20, 2009 at 1:17 PM, Paolo Craveri <[email protected]> wrote: > Hi all > > I cannot understand why v.to.db needs a connected table on layer 1 to > upload values on table linked to layer 2; e.g.: > > # # # spearfish60 > g.copy vect=archsites,mypoints --o > v.category in=mypoints out=mypoints2 layer=2 opt=add --o > # # # remove connection from layer 1 > v.db.connect -d mypoints2 layer=1 > # # # remove table from layer 1 > db.droptable mypoints2 -f > # # # create a table > echo "CREATE TABLE mypoints2_2 (cat integer, x double precision, y double > precision)" | db.execute (note that there is v.db.addtable) > # # # connect table to layer 2 > v.db.connect map=mypoints2 layer=2 key=cat table=mypoints2_2 > # # # try v.to.db to upload some values to table on layer 2 without > table on layer 1 > v.to.db mypoints2 layer=2 opt=cat col=cat > v.to.db mypoints2 layer=2 opt=coor col=x,y > # # # get an error: > # # # ERROR: Database connection not defined for layer 1. Use v.db.connect > first. Yes, I also get this and don't think that it is correct. Looking at the code I see http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/vector/v.to.db/main.c#L44 Fi = Vect_get_field(&Map, options.field); I added a local debug statement and found options.field==2 as you defined via "layer=2". Subsequently nothing is found since AFAIK the fields internally start with 0, not one. I may be wrong though. Anyone here having an idea? The function is: http://download.osgeo.org/grass/grass6_progman/field_8c-source.html#l00400 struct field_info *Vect_get_field(struct Map_info *Map, int field) Markus > # # # no error if layer 1 is connected to table > # # # create a foo table on layer 1 > v.db.addtable mypoints2 layer=1 > # # # v.to.db upload correctly values to table on layer 2 > v.to.db mypoints2 layer=2 opt=cat col=cat > v.to.db mypoints2 layer=2 opt=coor col=x,y > > Are there any particular reasons for that? > > ciao > > -- > -- > Paolo C. > Lat. 44° 39' 11.08'' N Long. 7° 23' 25.26'' E > > _______________________________________________ > grass-user mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/grass-user > > -- Open Source Geospatial Foundation http://www.osgeo.org/ http://www.grassbook.org/ _______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
