[GRASS-dev] GRASS 7 scripts overhaul

Michael Barton michael.barton at asu.edu
Mon Sep 12 20:27:48 EDT 2011


On Sep 13, 2011, at 12:11 AM, grass-dev-request at lists.osgeo.org wrote:

> Date: Mon, 12 Sep 2011 22:23:21 +0200
> From: Markus Neteler <neteler at osgeo.org>
> Subject: Re: [GRASS-dev] GRASS 7 scripts overhaul
> To: Glynn Clements <glynn at gclements.plus.com>
> Cc: GRASS developers list <grass-dev at lists.osgeo.org>
> Message-ID:
>        <CALFmHhvWkO5AUN9avv48wXGOXZp7pNV=4dhOebLsn6Ct2e7Khg at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> On Mon, Sep 12, 2011 at 8:24 PM, Glynn Clements
> <glynn at gclements.plus.com> wrote:
>> Markus Neteler wrote:
>> 
>>>> Try r48225.
>>> 
>>> Now a different one:
>> 
>>> line 267, in main
>>> ? ? y, z = yz.split(' ')
>>> ValueError: too many values to unpack
>> 
>> I've improved m.proj as much as I can.
> 
> Thanks for your efforts!
> 
> Still...
> 
> v.out.gps -t input=railroads output=trail.gpx
> Traceback (most recent call last):
>  File "/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/scripts/m.proj",
> line 288, in <module>
>    main()
>  File "/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/scripts/m.proj",
> line 267, in main
>    x, y = xy.split('\t')
> ValueError: need more than 1 value to unpack

I don't know this script, but this error means that the string xy has more than 2 items that are separated by a tab (or by a space in the earlier post). 

xy = "item_a item_b item_c"
x,y = xy.split(" ") 

will produce this error. There are several ways to fix it. 

1) change xy so that it is only containing 2 items
2) change the parsing of xy to: x,y = xy.split(" ")[0:2]
   (this gets the first 2 items and ignores the rest
3) put the statement inside an error trap like try/except

Michael

> 
>> The main problem is that, when cs2cs is run with the -E flag, it
>> appears to copy the input semi-verbatim, meaning that the output
>> format varies according to the input format. This makes it impossible
>> to reliably parse the output from cs2cs.
> 
> I believe that cs2cs should get the equivalent to the -g flag in GRASS which
> makes the output truely machine-readable.
> 
> Perhaps we concentrate on more important issues than v.out.gps and
> let it rest for now. Thanks, Glynn, I am sure that m.proj is way better now.
> 
> Markus



More information about the grass-dev mailing list