[GRASS-user] vector attribute calculation in grass python

Moritz Lennert mlennert at club.worldonline.be
Tue Aug 30 02:17:16 PDT 2016


Dear Alassane,

Please keep conversations on the list.

On 29/08/16 19:49, alassane toure wrote:
> Dear Moritz,
> I am a newbi in python programming.  Following your instructions i added
> the followings..
>
> par_sqf=[]
> c_number=[]
> pchng=[]
>
> but pchng stayed NULL for all rows (see below)!

You set pchng = range(len(par_sqf)),
but par_sqf is only defined as a Python variable by

par_sqf=[]

so it is normal that it is NULL.

Don't mix up Python variables and vector map column names.

If you want to set the attribute column pchng to contain a value that is 
equal to the length of the value of the attribute column par_sqf (i.e. 
count the number of digits (plus decimal point) in the area value), then 
you have to use v.db.update:

v.db.update map=parcel column=pchng qcol="length(par_sqf)"

Although I don't understand what the sens of such a length would be.

Maybe it would be easier if you explained us what you are trying to do, 
instead of only how you are doing it.

Moritz


More information about the grass-user mailing list