[GRASS-user] v.to.rast in a python loop, error
Scott Sinclair
scott.sinclair.za at gmail.com
Wed Feb 8 06:46:33 EST 2012
On 8 February 2012 11:35, Johannes Radinger <JRadinger at gmx.at> wrote:
> I try to run v.to.rast of a line in a loop
> to get a raster for each attribute of the vector (multiple columns).
> Therefore I created a short python script, which is working
> expept for that I am getting error messages:
> ERROR: option <output>: <raster_attribute> exists.
>
> Here the code:
>
> #!/usr/bin/env python
>
> import sys
>
> import grass.script as grass
> import grass.script.setup as gsetup
>
> def main():
>
> for i in ['FULL_HYDRO','LENGTH']:
>
> grass.run_command("v.to.rast",
> input = "streams at PERMANENT",
> output = "rast_"+i,
> type = "line",
> use = "attr",
> column = i)
>
> return 0
>
> if __name__ == "__main__":
> sys.exit(main())
Have you tried adding flags = '-o' as an argument to
grass.run_command? That will overwrite the output raster if it already
exists.
Cheers,
Scott
More information about the grass-user
mailing list