Re: [GRASS-user] else if in GRASS GIS

2021-01-01 Thread mega saputra
It succeed with no error. I add a little syntax :

r.mapcalc --overwrite expression=awan = if( "rgb.1@PERMANENT" > 1810.88
 &&  "rgb.1@PERMANENT" < 23442.12  &&  "rgb.3@PERMANENT" > 673.148594
 &&  "rgb.3@PERMANENT" < 22729.389558 , 0, if("rgb.1@PERMANENT" == 0, 255,
100))

Thank you

On Fri, Jan 1, 2021 at 9:32 PM Micha Silver  wrote:

>
> On 1/1/21 3:25 PM, mega saputra wrote:
>
> Hello guys,
>
> I try to create conditional statement. When I running the formula in
> GRASS, there is error. Can someone help me to convert in GRASS formula
> format. The formula is something like :
>
> if ( rgb.1 > 1810.88) and ( rgb.1 < 23442.12 ) and (rgb.2 >
> 673.148594) and (rgb.2 < 22729.389558) then 0 else if rgb.1 = 0 then 255
> else 100
>
> I have try, but with error. My false formula :
> r.mapcalc --overwrite expression=awan = if ( rgb.1 > 1810.88  &  rgb.1
> < 23442.12  &  rgb.2 > 673.148594  &  rgb.2 < 22729.389558 , 0) else if
> ( rgb.1 = 0, 255, 100)
>
>
> There is no "else" in mapcalc. You put the else expression after the
> second comma.
>
> Should be:
>
> r.mapcalc --o "awan = if(rgb.1 > 1810.88  &&  rgb.1 < 23442.12
> &&  rgb.2 > 673.148594  &  rgb.2 < 22729.389558 , 0, if(rgb.1 = 0, 255,
> 100))
>
>
> syntax error, unexpected NAME, expecting $end
> Parse error
> ERROR: parse error
>
> Any suggestion?
>
> Regards,
> mega
>
> ___
> grass-user mailing 
> listgrass-user@lists.osgeo.orghttps://lists.osgeo.org/mailman/listinfo/grass-user
>
> --
> Micha Silver
> Ben Gurion Univ.
> Sde Boker, Remote Sensing Lab
> cell: +972-523-665918
>
>
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] else if in GRASS GIS

2021-01-01 Thread Micha Silver

  
  


On 1/1/21 3:25 PM, mega saputra wrote:


  
  
Hello guys,


I try to create conditional statement. When I running the
  formula in GRASS, there is error. Can someone help me to
  convert in GRASS formula format. The formula is something like
  :


if ( rgb.1 > 1810.88) and ( rgb.1 < 23442.12
  ) and (rgb.2 > 673.148594) and (rgb.2 < 22729.389558)
  then 0 else if rgb.1 = 0 then 255 else 100


I have try, but with error. My false formula :
r.mapcalc --overwrite _expression_=awan = if ( rgb.1 >
1810.88  &  rgb.1 < 23442.12  &  rgb.2 >
673.148594  &  rgb.2 < 22729.389558 , 0) else if ( rgb.1
= 0, 255, 100)
  



There is no "else" in mapcalc. You put the else _expression_ after
  the second comma.

Should be:
r.mapcalc --o "awan = if(rgb.1 > 1810.88  && 
  rgb.1 < 23442.12  &&  rgb.2 > 673.148594  & 
  rgb.2 < 22729.389558 , 0, if(rgb.1 = 0, 255, 100))



  syntax error, unexpected NAME, expecting $end
Parse error
ERROR: parse error


Any suggestion?


Regards,
mega

  
  
  
  ___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user


-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918
  

___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user