[GRASS-user] map calculator in python loop
Alessandro Sebastiani
alessandro.sebastiani at uniroma1.it
Thu Dec 13 00:15:05 PST 2018
dear all,
i found where the error was! i didn't set the "g.list" command properly, in
fact the map calculator could not find maps . However , here it is how i
ran the mapcalc:
> gscript.mapcalc ( " %s = %s * %s " % ((r+"k") , r , c))
to Frank : k is just a suffix i wanted to use in order to give to the new
map a name similar to the older map (r in this case)
Il giorno mer 12 dic 2018 alle ore 13:01 Frank David <frank.david at geophom.fr>
ha scritto:
> Hi,
>
> What do you want to do with "k" ?
>
> Can you send what return gscript.verbose(( " %s = %s * %s ") % (r , r ,
> c))
>
> Frank
> Le 12/12/2018 à 17:34, Alessandro Sebastiani a écrit :
> > I get the same error after trying with your suggestion! I tried to
> > define rasters in different ways, like
> > >> c = ["costante"] ,
> > but nothing seems to change
> >
> > Il giorno mer 12 dic 2018 alle ore 10:22 Moritz Lennert
> > <mlennert at club.worldonline.be <mailto:mlennert at club.worldonline.be>>
> > ha scritto:
> >
> > On 12/12/18 12:59, Alessandro Sebastiani wrote:
> > > dear all,
> > > i'm dealing this time with r.mapcalc. I have different rasters
> > which i
> > > grouped using g.list.
> > > Now r_list contains all my raster. I want to multiply those
> > rasters to
> > > another raster (called "costante") in order to obtain a new
> > map, that i
> > > want to call as r followed by the letter "k"
> > > Here it is what i've done:
> > > import grass.script as gscript
> > > >>> r_list = gscript.read_command("g.list" , type = "rast"
> > > ).strip().split("\n")
> > > >>> c = " costante"
> > > >>> for r in r_list:
> > > >>> gscript.mapcalc ( " %s = %s * %s " % ((r+"k") , r , c))
> >
> > Try
> >
> > " %sk = %s * %s " % (r , r , c) "
> >
> > Moritz
> >
> >
> > _______________________________________________
> > grass-user mailing list
> > grass-user at lists.osgeo.org
> > https://lists.osgeo.org/mailman/listinfo/grass-user
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20181213/89151abe/attachment.html>
More information about the grass-user
mailing list