[GRASS-dev] grass, python, Pygrass

Ivan Marchesini ivan.marchesini at gmail.com
Tue Jun 25 21:40:59 PDT 2013


Dear grass-developers
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:

    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??

many thanks

Ivan





More information about the grass-dev mailing list