Hi all,
Can anyone please help me to solve the error with ‘@’ mark which comes along with mapset in python GRASS script. I get the following error when I run “mapcal.py”
syntax error, unexpected ‘@’, expecting ‘(’
mapcal.py
import grass.script as g
lis=[‘a@mapset’,‘b@mapset’]
for i in lis:
g.mapcalc(“{tmp_NDVI}=float({NIR}-Red})/float({NIR}+{Red})”.format(tmp_NDVI=‘NDVI’+str(i), NIR=‘B5@mapset’,Red=‘B4@mapset’),overwrite=True)
Thanks,
Looks like you missed one { before of Red. Don’t know…maybe isn’t it bur give a try.
Maxi
Il 01/Lug/2016 06:15, “Vinay Elothunkal” <vinay223333@gmail.com> ha scritto:
Hi all,
Can anyone please help me to solve the error with ‘@’ mark which comes along with mapset in python GRASS script. I get the following error when I run “mapcal.py”
syntax error, unexpected ‘@’, expecting ‘(’
mapcal.py
import grass.script as g
lis=[‘a@mapset’,‘b@mapset’]
for i in lis:
g.mapcalc(“{tmp_NDVI}=float({NIR}-Red})/float({NIR}+{Red})”.format(tmp_NDVI=‘NDVI’+str(i), NIR=‘B5@mapset’,Red=‘B4@mapset’),overwrite=True)
Thanks,
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user
Hai Maxi,
Sorry, I missed { when I write the mail, but while running I have used it correctly, still same error!
regards,
Vinay
···
On Fri, Jul 1, 2016 at 1:51 PM, Massimiliano Cannata <massimiliano.cannata@supsi.ch> wrote:
Looks like you missed one { before of Red. Don’t know…maybe isn’t it bur give a try.
Maxi
Il 01/Lug/2016 06:15, “Vinay Elothunkal” <vinay223333@gmail.com> ha scritto:
Hi all,
Can anyone please help me to solve the error with ‘@’ mark which comes along with mapset in python GRASS script. I get the following error when I run “mapcal.py”
syntax error, unexpected ‘@’, expecting ‘(’
mapcal.py
import grass.script as g
lis=[‘a@mapset’,‘b@mapset’]
for i in lis:
g.mapcalc(“{tmp_NDVI}=float({NIR}-Red})/float({NIR}+{Red})”.format(tmp_NDVI=‘NDVI’+str(i), NIR=‘B5@mapset’,Red=‘B4@mapset’),overwrite=True)
Thanks,
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user
Shouldn’t there be spaces around the first equal sign:
"{tmp_NDVI} = float …
···
On Fri, Jul 1, 2016 at 1:51 PM, Massimiliano Cannata <massimiliano.cannata@supsi.ch> wrote:
Looks like you missed one { before of Red. Don’t know…maybe isn’t it bur give a try.
Maxi
Il 01/Lug/2016 06:15, “Vinay Elothunkal” <vinay223333@gmail.com> ha scritto:
Hi all,
Can anyone please help me to solve the error with ‘@’ mark which comes along with mapset in python GRASS script. I get the following error when I run “mapcal.py”
syntax error, unexpected ‘@’, expecting ‘(’
mapcal.py
import grass.script as g
lis=[‘a@mapset’,‘b@mapset’]
for i in lis:
g.mapcalc(“{tmp_NDVI}=float({NIR}-Red})/float({NIR}+{Red})”.format(tmp_NDVI=‘NDVI’+str(i), NIR=‘B5@mapset’,Red=‘B4@mapset’),overwrite=True)
Thanks,
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user
Hi Paulo,
Thanks for your reply, I guess I didnt explain the question properly , Inherently the problem is residing in @ mark as it shown in below example…
GRASS 7.0.4 (Peureto_rico):~/Home_copy/ > r.mapcalc
Enter expressions, “end” when done.
mapcalc> test10=Senti_AOI1_NIR_10m@Sentinel2+Senti_AOI1_SWIR_20m@Sentinel2
mapcalc>
100%
GRASS 7.0.4 (Peureto_rico):~/Home_copy/ > r.mapcalc
Enter expressions, “end” when done.
mapcalc> test10@Sentinel2=Senti_AOI1_NIR_10m@Sentinel2+Senti_AOI1_SWIR_20m@Sentinel2
syntax error, unexpected ‘@’, expecting ‘(’
On Jul 2, 2016 5:55 AM, “Vinay Elothunkal” <vinay223333@gmail.com> wrote:
…
test10@Sentinel2=Senti_AOI1_NIR_10m…
AFAIK there cannot be a @ sign on the left hand side of the r.mapcalc equation.
Markus
I assume it is not acceptable that you create a map in a different mapset from your. Maybe you could change the mapset, mapcalc and switch again back.
Maxi
Il 02/Lug/2016 05:54, “Vinay Elothunkal” <vinay223333@gmail.com> ha scritto:
Hi Paulo,
Thanks for your reply, I guess I didnt explain the question properly , Inherently the problem is residing in @ mark as it shown in below example…
GRASS 7.0.4 (Peureto_rico):~/Home_copy/ > r.mapcalc
Enter expressions, “end” when done.
mapcalc> test10=Senti_AOI1_NIR_10m@Sentinel2+Senti_AOI1_SWIR_20m@Sentinel2
mapcalc>
100%
GRASS 7.0.4 (Peureto_rico):~/Home_copy/ > r.mapcalc
Enter expressions, “end” when done.
mapcalc> test10@Sentinel2=Senti_AOI1_NIR_10m@Sentinel2+Senti_AOI1_SWIR_20m@Sentinel2
syntax error, unexpected ‘@’, expecting ‘(’