[GRASS-dev] problem with parse_command python

Luca Delucchi lucadeluge at gmail.com
Thu Dec 23 08:33:47 EST 2010


Hi all, I'm working for a new module using python but I have a strange
problem with parse_command and v.what. When I have a "good dictionary"
(setting parse = (grass.parse_key_val, { 'sep' : ':' })) I can see
only the attributes of one feature, with a "bad dictionary" I see all
the features but I can't work with them

Here the code

coor='647220.0,5084994.0'
map_tiles='test_tile'

## this return all the features but the dictionary is bad
>>> grass.parse_command('v.what',flags = 'a', map = map_tiles, east_north = coor)
 100%
{'': None, 'Category: 2': None, 'location :
/grassdata/patUTM32/ortofoto_baldo/cellhd/22a_4597_tagliata': None,
'North: 5084994': None, 'Category: 4': None, 'cat : 1': None,
'location : /grassdata/patUTM32/ortofoto_baldo/cellhd/22_1684_tagliata':
None, 'cat : 2': None, 'cat : 5': None, 'Table: test_tile': None,
'location : /grassdata/patUTM32/ortofoto_baldo/cellhd/22a_4596_tagliata':
None, 'Acres: 571.248': None, 'location :
/grassdata/patUTM32/ortofoto_baldo/cellhd/22a_4598_tagliata': None,
'cat : 3': None, 'Key column: cat': None, 'Sq Miles: 0.8926': None,
'Sq Meters: 2311760.000': None, 'Hectares: 231.176': None, 'location :
/grassdata/patUTM32/ortofoto_baldo/cellhd/22_1683_tagliata': None,
'East: 647220': None, 'Layer: 2': None, 'Layer: 1': None, 'Mapset:
ortofoto_baldo': None, 'Category: 1': None, 'Category: 3': None,
'Driver: dbf': None, 'Category: 5': None, 'Map: test_tile': None,
'Type: Area': None, 'Database:
/grassdata/patUTM32/ortofoto_baldo/dbf/': None, 'cat : 4': None}

##this return only a features but the dictionary is good
>>> grass.parse_command('v.what',flags = 'a', map = map_tiles, east_north = coor, parse = (grass.parse_key_val, { 'sep' : ':' }))
 100%
{'': None, 'Map': ' test_tile ', 'Layer': ' 2', 'North': ' 5084994',
'Sq Miles': ' 0.8926', 'Database': '
/grassdata/patUTM32/ortofoto_baldo/dbf/', 'Type': ' Area', 'cat': '
5', 'Driver': ' dbf', 'Category': ' 5', 'Acres': ' 571.248',
'Hectares': ' 231.176', 'Sq Meters': ' 2311760.000', 'location': '
/grassdata/patUTM32/ortofoto_baldo/cellhd/22a_4598_tagliata', 'Table':
' test_tile', 'East': ' 647220', 'Mapset': ' ortofoto_baldo', 'Key
column': ' cat'}

I also try to use flags = 'ag', but I can only have the second
solution (with one features)

Is there a problem in parse_command or I do something wrong?

thanks
Luca


More information about the grass-dev mailing list