[GRASS-user] Using a variable inside GRASS commands with Python code
Anna Kratochvílová
kratochanna at gmail.com
Mon Jan 7 23:55:36 PST 2013
Hi Brian,
On Tue, Jan 8, 2013 at 6:51 AM, Brian Sanjeewa Rupasinghe
<jinkabs at gmail.com> wrote:
> Hi all
>
> I am generating viewshed of each observer location by iterating through a
> set of observer coordinate file through
> Python code in Windows 7 . Below is the python command used in grass for
> each iteration. According to this, each time
> loop iterates, output is overwritten with the same name. Now what i need is
> to keep each output of all the observer locations. For this, i need to
> concatanate output name (i.e. 'viewshed' with loop index i which will be
> 'viewshed' + str(i) ). How is that possible within
> this grass.run_command?
>
just set a variable within each loop and use it in the run_command:
for i in ... :
out = 'viewshed' + str(i)
grass.run_command('r.viewshed', input = rinput, output = out, ...)
Regards,
Anna
> grass.run_command('r.viewshed', input = rinput, output = 'viewshed',
> coordinate = [x,y], obs_elev = oelv, tgt_elev = th, memory = 4098, flags =
> 'b', overwrite = True, quiet = True)
>
> Cheers, Brian
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
More information about the grass-user
mailing list