[GRASS-dev] Write array to (point) attribute table
Paulo van Breugel
p.vanbreugel at gmail.com
Wed Sep 30 00:51:18 PDT 2015
On Wed, Sep 30, 2015 at 2:02 AM, Anna Petrášová <kratochanna at gmail.com>
wrote:
>
>
> On Tue, Sep 29, 2015 at 6:09 PM, Paulo van Breugel <p.vanbreugel at 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
> Anna
>
> [1]
> https://grass.osgeo.org/grass70/manuals/libpython/pygrass_vector.html#working-with-vector-objects
>
>>
>> Cheers,
>>
>> Paulo
>>
>> _______________________________________________
>> grass-dev mailing list
>> grass-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/grass-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20150930/6514bfba/attachment.html>
More information about the grass-dev
mailing list