[GRASS-dev] pygrass: how to use GridModule with a module that has a 'width' parameter

Vaclav Petras wenzeslaus at gmail.com
Thu Mar 8 06:18:44 PST 2018


On Tue, Mar 6, 2018 at 8:59 AM, Moritz Lennert <mlennert at club.worldonline.be
> wrote:

> Hi,
>
> I'm trying to run the i.zc module in parallel on several tiles. I use this
> syntax
>
>     if options['tile_width']:
>         parallel = True
>         width = int(options['tile_width'])
>         height = int(options['tile_height'])
>         overlap = int(options['overlap'])
>
>     processes = int(options['processes'])
>
>
>
> kwargs = {'input' : inputraster,
>           'output' : temp_edge_map,
>           'width' : int(options['zc_width']),
>           'threshold' : float(options['zc_threshold']),
>           'quiet' : True}
>
> if parallel:
>    grd = GridModule('i.zc',
>                     width=width,
>                     height=height,
>                     overlap=overlap,
>                     processes=processes,
>                     split=False,
>                     **kwargs)
>
>
> However, this fails (understandably) with
>
> TypeError: type object got multiple values for keyword argument 'width'
>
> Is there a way to work around this name conflict ? Do I have to define my
> own class derived from GridModule to change the parameter names ?
>

Try `width_` instead of `width` for the module parameter. This is how
grass.script works (mostly to avoid conflicts with Python keywords namely
lambda), but without checking the code, I don't know if PyGRASS has this
implemented.

Vaclav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20180308/1952e9c0/attachment.html>


More information about the grass-dev mailing list