[GRASS-user] v.extract where clause with puthon script

Dear all,

i'm trying to extract some vectors using attribute names using python script: (grass 6.4.4)

i have a column with "des" values : river, canal
and i have to extract only the features of type 'canal'
then of type 'river' and so on...

#######################################

import grass.script as grass

env = grass.gisenv()

grass.run_command('v.extract', input='idro', output='canal_idro', where='des = canal', overwrite='True')

#################################################################################

maybe i'm missing the correct sintiax of the "where" clause because i only get
a buffer overflow as result,

thanks for any help,

Roy.

On Sat, Feb 14, 2015 at 4:00 PM, Roy <royroge@outlook.com> wrote:

Dear all,

i'm trying to extract some vectors using attribute names using python
script: (grass 6.4.4)

i have a column with "des" values : river, canal
and i have to extract only the features of type 'canal'
then of type 'river' and so on...

#######################################

import grass.script as grass

env = grass.gisenv()

grass.run_command('v.extract', input='idro', output='canal_idro', where='des
= canal', overwrite='True')

#################################################################################

maybe i'm missing the correct sintiax of the "where" clause because i only
get a buffer overflow as result,

You need to quote the text string "canal", i.e. where='des = "canal"'

Here a NC dataset example

grass.run_command('v.extract', input='roadsmajor', output='nc55',
where='ROAD_NAME = "NC-55"', overwrite='True')

HTH,
Markus

Dear Markus,

it works using sqlite as database provider both in GRASS 6.4.4 and GRASS 7.0.0 R.C.2,

i was not aware that GRASS overrides the sqlite limitation "cannot drop column", really a nice feature to have,

thank you very much,

Roy.

Il 14/02/2015 17.44, Markus Neteler ha scritto:

On Sat, Feb 14, 2015 at 4:00 PM, Roy <royroge@outlook.com> wrote:

grass.run_command('v.extract', input='idro', output='canal_idro', where='des
= canal', overwrite='True')

#################################################################################

maybe i'm missing the correct sintiax of the "where" clause because i only
get a buffer overflow as result,

You need to quote the text string "canal", i.e. where='des = "canal"'

Here a NC dataset example

grass.run_command('v.extract', input='roadsmajor', output='nc55',
where='ROAD_NAME = "NC-55"', overwrite='True')

HTH,
Markus