<div dir="ltr"><div>@Sotiris: I am not sure on Windows, but on Linux, using g.mlist in r.series as described in the help page works fine. Just be careful to use the different quotation marks as indicated. That is, the whole g.mlist statement should be within ` quotation marks, and that should be within in double quotation marks. E.g.,<span style="font-family:courier new,monospace"> r.series input="`g.mlist pattern=tmin* sep=,`"</span> </div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 8, 2013 at 6:19 PM, S. Koukoulas (lists) <span dir="ltr"><<a href="mailto:sotkouklistes@gmail.com" target="_blank">sotkouklistes@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Well, not a python solution, but you might find it useful.<br>
In Windows you could try the shell (command prompt) there as well:<br>
<br>
First get a list of your observers in a file, say obspoints.txt<br>
<br>
v.out.ascii input=myobs@user output=c:\obspoints.txt fs=, dp=2<br>
<br>
then run the shell's FOR command (run a help for more on the syntax)<br>
ALL must run in ONE LINE (and you must be running Grass in from the<br>
command prompt should be somewhere in the menu):<br>
<br>
FOR /F "tokens=1,2,3 delims=, " %i in (obspoints.txt) do r.los<br>
--overwrite input=mydtm@user output=obs%k coordinate=%i,%j<br>
(here tokens are the columns, X,Y,ID - and replace r.los with the newer<br>
r.viewshed)<br>
<br>
Then use g.mlist to make a list of your files<br>
g.mlist pattern=’obs*’ mapset=user sep=,<br>
<br>
and use the output of the list with r.series (method=sum) to get what<br>
you want.<br>
<br>
r.series --overwrite input=amap,bmap,... output=outshed method=sum<br>
<br>
(in r.series manual page, it is suggested that you could use g.mlist<br>
inside r.series but I have not managed to do it correctly -maybe someone<br>
can explain better the use of quotes?)<br>
<br>
HTH<br>
sotiris<br>
<div class="im"><br>
On 01/08/2013 06:53 PM, Brian Sanjeewa Rupasinghe wrote:<br>
> Hi,<br>
><br>
> Thanks again. Since i use GRASS 7.0, it will not work there. I do not<br>
> think it can either be installed in GRASS for Windows through Add-on<br>
> extensions. What about using grass.mapcalc to integrate each viewshed<br>
> if there is a method of handling variables in it? If not how about<br>
> using r.series with sum? Your advice is appreciated since i am<br>
> pretty new to GRASS.<br>
><br>
> On Tue, Jan 8, 2013 at 9:19 PM, Leonidas Liakos<br>
</div><div class="im">> <<a href="mailto:leonidas_liakos@yahoo.gr">leonidas_liakos@yahoo.gr</a> <mailto:<a href="mailto:leonidas_liakos@yahoo.gr">leonidas_liakos@yahoo.gr</a>>> wrote:<br>
><br>
>     Do you need cumulative viewshed analysis?<br>
>     Maybe r.cva is for you:<br>
>     <a href="http://www.ucl.ac.uk/~tcrnmar/GIS/r.cva.html" target="_blank">http://www.ucl.ac.uk/~tcrnmar/GIS/r.cva.html</a><br>
</div>>     <<a href="http://www.ucl.ac.uk/%7Etcrnmar/GIS/r.cva.html" target="_blank">http://www.ucl.ac.uk/%7Etcrnmar/GIS/r.cva.html</a>><br>
><br>
>     ------------------------------------------------------------------------<br>
>     *Απο:* Brian Sanjeewa Rupasinghe <<a href="mailto:jinkabs@gmail.com">jinkabs@gmail.com</a><br>
>     <mailto:<a href="mailto:jinkabs@gmail.com">jinkabs@gmail.com</a>>><br>
>     *Προς:* Anna Kratochvílová <<a href="mailto:kratochanna@gmail.com">kratochanna@gmail.com</a><br>
>     <mailto:<a href="mailto:kratochanna@gmail.com">kratochanna@gmail.com</a>>>; <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
>     <mailto:<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>><br>
>     *Στάλθηκε:* 2:45 μ.μ. Τρίτη, 8 Ιανουαρίου 2013<br>
>     *Θέμα:* Re: [GRASS-user] Using a variable inside GRASS commands<br>
<div class="im">>     with Python code/ grass.mapcalc<br>
><br>
>     Hi,<br>
><br>
>     Many thanks. It worked for me. Then i have a similar problem in<br>
>     GRASS.mapcalc. What i need next is to add viewshed of each<br>
>     observer location cumulatively while looping through the observer<br>
>     locations in order to have final integrated viewshed analysis map.<br>
>     So i used the following command in Python (some code ommitted)<br>
><br>
>     for i in:<br>
>     grass.run_command('r.viewshed', input = rinput, output =<br>
>     'viewshed', coordinate = [x,y], obs_elev = oelv, tgt_elev = th,<br>
>     memory = 4098, flags = 'b', overwrite = True, quiet = True)<br>
><br>
>     grass.mapcalc("viewshed_cum = viewshed + viewshed_cum", overwrite<br>
>     = True, quiet = True)<br>
><br>
>     It seems that expressions like sum = c + sum does not work inside<br>
</div>>     <a href="http://grass.mapcalc.Is" target="_blank">grass.mapcalc.Is</a> <<a href="http://grass.mapcalc.is/" target="_blank">http://grass.mapcalc.is/</a>> there any alternative<br>
<div class="im">>     or other way around to get this done? I am using GRASS 7 in Windows 7.<br>
><br>
>     Cheers, Brian<br>
><br>
>     On Tue, Jan 8, 2013 at 1:25 PM, Anna Kratochvílová<br>
</div><div class="im">>     <<a href="mailto:kratochanna@gmail.com">kratochanna@gmail.com</a> <mailto:<a href="mailto:kratochanna@gmail.com">kratochanna@gmail.com</a>>> wrote:<br>
><br>
>         Hi Brian,<br>
><br>
>         On Tue, Jan 8, 2013 at 6:51 AM, Brian Sanjeewa Rupasinghe<br>
</div><div><div class="h5">>         <<a href="mailto:jinkabs@gmail.com">jinkabs@gmail.com</a> <mailto:<a href="mailto:jinkabs@gmail.com">jinkabs@gmail.com</a>>> wrote:<br>
>         > Hi all<br>
>         ><br>
>         > I am generating viewshed of each observer location by<br>
>         iterating through a<br>
>         > set of observer coordinate file through<br>
>         > Python code in Windows 7 . Below is the python command used<br>
>         in grass for<br>
>         > each iteration. According to this, each time<br>
>         > loop iterates, output is overwritten with the same name. Now<br>
>         what i need is<br>
>         > to keep each output of all the observer locations. For this,<br>
>         i need to<br>
>         > concatanate output name (i.e. 'viewshed' with loop index i<br>
>         which will be<br>
>         > 'viewshed' + str(i) ). How is that possible within<br>
>         > this grass.run_command?<br>
>         ><br>
><br>
>         just set a variable within each loop and use it in the<br>
>         run_command:<br>
>         for i in ... :<br>
>         out = 'viewshed' + str(i)<br>
>         grass.run_command('r.viewshed', input = rinput, output = out, ...)<br>
><br>
><br>
>         Regards,<br>
>         Anna<br>
><br>
>         > grass.run_command('r.viewshed', input = rinput, output =<br>
>         'viewshed',<br>
>         > coordinate = [x,y], obs_elev = oelv, tgt_elev = th, memory =<br>
>         4098, flags =<br>
>         > 'b', overwrite = True, quiet = True)<br>
>         ><br>
>         > Cheers, Brian<br>
>         ><br>
>         > _______________________________________________<br>
>         > grass-user mailing list<br>
</div></div>>         > <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a> <mailto:<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>><br>
<div class="im">>         > <a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
>         ><br>
><br>
><br>
><br>
>     _______________________________________________<br>
>     grass-user mailing list<br>
</div>>     <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a> <mailto:<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>><br>
<div class="HOEnZb"><div class="h5">>     <a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
><br>
><br>
><br>
><br>
><br>
> _______________________________________________<br>
> grass-user mailing list<br>
> <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
<br>
_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
</div></div></blockquote></div><br></div>