[GRASS-user] i.group with patterns as name for input

umberto.minora umberto.minora at unimi.it
Wed Apr 1 08:48:36 PDT 2015


Dear Nikos (and again Pietro, thanks)

I am trying this, but GRASS ouputs a Windows error, then the script
continues (very strange) and outputs an error:

from grass.script.core import run_command
from grass.script import parse_command

dem="khumbu_dem"
aspect= "khumbu_aspect"
slope= "khumbu_slope"

outFolder=
"D:\UMBE\PhD\Nepal\khumbu_article\shadow\r_sun_hourly\prova_hourly_shadow"

day_month=[range(1,3),range(3,5)]

for m in xrange(len(day_month)):
	group_list= []
	for d in day_month[m]:
		run_command("r.sun.hourly",
					flags="b",
					elevation=dem,
					aspect=aspect,
					slope=slope,
					start_time=0,
					end_time=3,
					day=d,
					year=2014,
					beam_rad_basename="prova"+ str(m+1)+ "_"+ str(d)) # Underscore and hour
are added to the base name for each map

	group_list= parse_command("g.list",
							  type="raster",
							  pattern="prova"+ str(m+1)).keys()
							  
	run_command("i.group",
				group="prova"+ str(m+1),
				input=group_list)

	run_command("r.out.gdal",
				flags="c",
				type="Byte",
				input="prova"+ str(m+1),
				output=outFolder+ "\prova"+ str(m+1)+ ".tif",
				nodata=255)

As you can see I am using "i.group" to create a list (named "group_list")
which updates at each iteration (as you suggested in an  old quesion
<http://lists.osgeo.org/pipermail/grass-user/2014-November/071197.html>   I
posted). Anyway, I receive this error after the first "r.sun.hourly" loop:

Traceback (most recent call last):
  File "D:\UMBE\PhD\Nepal\khumbu_article\shadow\r_sun_hourly
\prova_r-sun-hourly.py", line 32, in <module>
    input=group_list)
  File "C:\OSGeo4W\apps\grass\grass-7.0.0\etc\python\grass\s
cript\core.py", line 375, in run_command
    return handle_errors(returncode, returncode, args,
kwargs)
  File "C:\OSGeo4W\apps\grass\grass-7.0.0\etc\python\grass\s
cript\core.py", line 310, in handle_errors
    returncode=returncode)
grass.exceptions.CalledModuleError: Module run None
['i.group', 'input=', 'group=prova1'] ended with error
Process ended with non-zero return code 255. See errors in
the (error) output.

It could be related to the fact that the option "input" of "i.group" should
be something like "a,b,c" and not "'a','b','c'" (as my variable "group_list"
is like)?



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/i-group-with-patterns-as-name-for-input-tp5196465p5196494.html
Sent from the Grass - Users mailing list archive at Nabble.com.


More information about the grass-user mailing list