[GRASS-user] Grass, Python, mapcalc

Rashad M mohammedrashadkm at gmail.com
Fri Dec 28 03:19:05 PST 2012


could you provide a source file to check?


On Fri, Dec 28, 2012 at 4:46 PM, Paul Meems <bontepaarden at gmail.com> wrote:

> Here I am again with some questions ;)
>
> I'm now trying to use r.sun and r.mapcalc with Python to create my annual
> solar radiation map.
> I'm using the Python shell inside GRASS.
>
> For testing purposes I start with 9 days.
> The r.sun part seems to be working:
> for x in range(1, 10, 1):
>     print "Working on day %d" % (x)
>     glob_rad = 'global' + str(x)
>     grass.run_command('r.sun', flags = 's', elevin = 'w001001 at temp',
> aspin = 'aspect at temp', slopein = 'slope at temp', glob_rad = glob_rad, day =
> x)
> I do have a question about parsing the --overwrite flag. How to do that.
> Adding flags='s, --overwrite' or flags='s, -overwrite' gives a compile
> error.
>
> Now I try to combine the results of r.sun into 1 raster.
> This is working:
> for x in range(1, 10, 1):
>     if x == 2:
>       exp = 'sun = global1 at temp + global2 at temp'
>       print exp
>       grass.mapcalc(exp, quiet=False, verbose=False, overwrite=True)
>
> This is also working:
> for x in range(1, 10, 1):
>     if x == 2:
>       exp = 'sun = global1 at temp + global2 at temp'
>       print exp
>       grass.mapcalc(exp, quiet=False, verbose=False, overwrite=True)
>     elif x > 2:
>       exp = 'sun = sun at temp + global' + str(x) + '@temp'
>       print exp
> and produces this output:
> sun = sun at temp + global3 at temp
> sun = sun at temp + global4 at temp
> sun = sun at temp + global5 at temp
> sun = sun at temp + global6 at temp
> sun = sun at temp + global7 at temp
> sun = sun at temp + global8 at temp
> sun = sun at temp + global9 at temp
> But when I execute this using
> grass.mapcalc(exp, quiet=False, verbose=False, overwrite=True)
>  Grass crashes completely.
>
> Has this something to do with having the output file is the input file as
> well?
> If this is not allowed how can I combine all output files from r.sun into
> 1 raster?
>
> Thanks,
>
> Paul
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
>


-- 
Regards,
   Rashad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20121228/d48d3de8/attachment.html>


More information about the grass-user mailing list