<div class="gmail_quote"><div><br></div><div>Hi,</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
><br>
> > Have you tried adding flags = '-o' as an argument to<br>
> > grass.run_command? That will overwrite the output raster if it already<br>
> > exists.<br>
><br>
> Actually, it will raise a ScriptError if you're running anything later<br>
> than 6.4.1. If you want to pass the --overwrite flag to the module,<br>
> you should pass overwrite=True to run_command() etc.<br>
<br>
so if I understand you correctly: This error is normal to GRASS6.5SVN?<br>
<br>
It is really an interesting behavior. I remove the raster maps manually (with g.remove and f-flag) and cross check (g.list) so that the raster maps a really removed. Although the script gives this error...<br>
However when I include g.remove in the script to remove them before v.to.rast everything works fine.<br>
Interestingly when I include g.list before v.to.rast in the script (and all raster maps were removed before), g.list states that the maps are existing... So it seems that there is somehow a problem with the script/pyhton/GRASS interaction... although it works for Moritz Lennert.<br>
Somehow it seems that v.to.rast has two passes (or more)...and the first one is performed even before g.list is processed in the script???<br>
<br>
About my setup: GRASS6.5SVN (rev50782) on Mac OS X, Python 2.6.6...<br>
<br>
and here the script with g.remove and g.list:<br>
<br>
#!/usr/bin/env python<br>
<br>
import sys<br>
<br>
import grass.script as grass<br>
import grass.script.setup as gsetup<br>
<br>
def main():<br>
<br>
<br>
#grass.run_command("g.remove",<br>
# flags = "f",<br>
# rast = "rast_FULL_HYDRO,rast_LENGTH")<br>
<br>
grass.run_command("g.list",<br>
type = "rast")<br>
<br>
<br>
<br>
for i in ['FULL_HYDRO','LENGTH']:<br>
<br>
grass.run_command("v.to.rast",<br>
input = "streams@PERMANENT",<br>
output = "rast_"+i,<br>
type = "line",<br>
use = "attr",<br>
column = i)<br>
<br>
return 0<br>
<br>
if __name__ == "__main__":<br>
sys.exit(main())<br>
<br>
<br>
<br>
And my output with although all maps were removed manually with g.remove and cross checked:<br>
<br>
Launching script '/Users/Johannes Radinger/Desktop/test2.py'...<br>
(Mon Feb 13 11:12:27 2012)<br>
/Users/Johannes Radinger/Desktop/test2.py<br>
----------------------------------------------<br>
raster files available in mapset <PERMANENT>:<br>
basins elevation_shade lakes soils<br>
elevation geology landuse<br>
raster files available in mapset <user1>:<br>
rast_FULL_HYDRO rast_LENGTH<br>
----------------------------------------------<br>
ERROR: option <output>: <rast_FULL_HYDRO> exists.<br>
ERROR: option <output>: <rast_LENGTH> exists.<br>
(Mon Feb 13 11:12:27 2012) Command finished (0 sec)<br></blockquote><div><br></div><div> </div><div>Please try quiet option to remove them. Furthermore, remove them separately:</div><div><br></div><div>grass.run_command('g.remove', rast = 'rast_FULL_HYDRO', quiet = True) </div>
<div>grass.run_command('g.remove', rast = 'rast_LENGTH', quiet = True) </div><div><br></div><div>HTH,</div><div>regards madi</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<br>
Of course I can use the overwrite-flag (overwrite=TRUE) to overcome the problem (or use g.remove in the script). I just wanted to know if that is a plattform specific problem, a problem with my script or just a bug in the GRASS-Python code...<br>
<br>
Best regards<br>
/johannes<br>
<br><br>
</blockquote></div><br>