[GRASS-dev] grass, python, Pygrass
Luca Delucchi
lucadeluge at gmail.com
Wed Jun 26 00:28:49 PDT 2013
On 26 June 2013 06:40, Ivan Marchesini <ivan.marchesini at gmail.com> wrote:
> Dear grass-developers
Ciao Ivan
> I'm working with Python, GRASS and Pygrass and I have some small
> problems probably due to my poor knowledge of Python.
> I would ask your help.
>
> I have this small code:
>
this is not your code right?
> grass.run_command("v.to.rast", input=ocs, type="line", output="tmp_ocs", use="val", overwrite=True)
> grass.mapcalc("$outmap = $a", a = dtm, outmap="demcut", overwrite = true)
> grass.run_command("g.remove", rast="visitati")
>
> np_ocs = raster.RasterNumpy("tmp_ocs")
> np_ocs.open()
> visited=np_ocs*0
> visited.open()
>
> for i in range(1,new.shape[0]-1):
> for j in range(1,new.shape[1]-1):
> if np_ocs[i,j] == 1:
> visited[i,j] = 1
> else:
> visited[i,j] = 3
>
> visited.name='visitati'
> visited.close()
> sys.exit("stop")
>
>
> When I run it I obtain a lot of:
>
> WARNING: rast=visitati,visitati: files could be the same, no rename
> possible
>
> I cannot understand where the warnings arise... and why..
>
> can you help me??
>
probably your run more than one your script?
probably you have to add visited.overwrite = True before close your map
please let us know
> many thanks
>
> Ivan
>
--
ciao
Luca
http://gis.cri.fmach.it/delucchi/
www.lucadelu.org
More information about the grass-dev
mailing list