Dear Glynn,
Dear Moritz,
Dear Scott,
>
> > Have you tried adding flags = '-o' as an argument to
> > grass.run_command? That will overwrite the output raster if it already
> > exists.
>
> Actually, it will raise a ScriptError if you're running anything later
> than 6.4.1. If you want to pass the --overwrite flag to the module,
> you should pass overwrite=True to run_command() etc.
so if I understand you correctly: This error is normal to GRASS6.5SVN?
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...
However when I include g.remove in the script to remove them before v.to.rast
everything works fine.
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.
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???
About my setup: GRASS6.5SVN (rev50782) on Mac OS X, Python 2.6.6...
and here the script with g.remove and g.list:
#!/usr/bin/env python
import sys
import grass.script as grass
import grass.script.setup as gsetup
def main():
#grass.run_command("g.remove",
# flags = "f",
# rast = "rast_FULL_HYDRO,rast_LENGTH")
grass.run_command("g.list",
type = "rast")
for i in ['FULL_HYDRO','LENGTH']:
grass.run_command("v.to.rast",
input = "streams@PERMANENT",
output = "rast_"+i,
type = "line",
use = "attr",
column = i)
return 0
if __name__ == "__main__":
sys.exit(main())
And my output with although all maps were removed manually with g.remove and
cross checked:
Launching script '/Users/Johannes Radinger/Desktop/test2.py'...
(Mon Feb 13 11:12:27 2012)
/Users/Johannes Radinger/Desktop/test2.py
----------------------------------------------
raster files available in mapset <PERMANENT>:
basins elevation_shade lakes soils
elevation geology landuse
raster files available in mapset <user1>:
rast_FULL_HYDRO rast_LENGTH
----------------------------------------------
ERROR: option <output>: <rast_FULL_HYDRO> exists.
ERROR: option <output>: <rast_LENGTH> exists.
(Mon Feb 13 11:12:27 2012) Command finished (0 sec)
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...
Best regards
/johannes
>
> --
> Glynn Clements <[email protected]>
> _______________________________________________
> grass-user mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/grass-user
--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://www.gmx.net/de/go/freephone/
_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user