On Wed, Sep 30, 2015 at 9:51 AM, Paulo van Breugel <p.vanbreu...@gmail.com> wrote: > > > On Wed, Sep 30, 2015 at 2:02 AM, Anna Petrášová <kratocha...@gmail.com> > wrote: >> >> >> >> On Tue, Sep 29, 2015 at 6:09 PM, Paulo van Breugel >> <p.vanbreu...@gmail.com> wrote: >>> >>> This must be a very basic question, but I can't find an easy/direct way >>> to do this. In python, if I have an array with values with a length equal to >>> the number of rows in an attribute table of a (point) vector layer, how can >>> I write those values to a new column in that attribute table. I can of >>> course first create the column, but than how to update that column with the >>> values in the array? >> >> >> it should be pretty easy to do with pygrass, unfortunately there is no >> example on assigning attributes in the official documentation [1], but it >> should be pretty easy, something like that (not tested): >> >> with VectorTopo('myvector', mode='w') as vectormap: >> for feature in vectormap: >> feature.attrs['mycolumn'] = value >> >> > Thanks, but that seems to write the vector back without attribute table
You have to save the changes in the database out from your cycle, with: vectormap.table.conn.commit() Pietro _______________________________________________ grass-dev mailing list grass-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-dev