[GRASS-dev] problem with parse_command python
Glynn Clements
glynn at gclements.plus.com
Tue Dec 28 23:15:35 EST 2010
Luca Delucchi wrote:
> I try to create a general function for v.what, it return a dictionary
> of dictionary
> # create string for east_north param
> coor = str(x) + ',' + str(y)
This isn't necessary; you can pass numbers, lists and tuples to the
grass.*_command() functions and they will be converted automatically.
> fields = grass.read_command('v.what',flags = 'a', map = map, east_north = coor)
I suggest using the -g flag.
> # split the different features
> fields = fields.split('\n\n')
This isn't correct. Without -g, the blank line occurs betwen the
Layer: and Category: lines and the rest of the per-layer information.
You need to scan through the lines and start a new dictionary whenever
you find a "Layer" line.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list