[GRASS-user] r.mapcalc and us of max value

Hi,

I'm able to get the max value of a raster map using the following command :

which return max = 45784578
and I use this value to create another raster like so :

Returns :

which appears to be correct

My question is : Is there a way to do it dynamically? I want to automatise
that into a bash script.

I've tried : /r.mapcalc "newrast = myrast * 100 / max(myrast)"/ expecting
max(myrast) returns here 45784578 (max value) with no success.

returns :

which appears to be incorrect.

Any help would be appreciated.

Thanks,
simon

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/r-mapcalc-and-us-of-max-value-tp5049643.html
Sent from the Grass - Users mailing list archive at Nabble.com.

···

It looks like something in your formatting has cut our part of the message.
In any case, in a bash script I would do:

MAX=r.univar -g map=<your raster> | grep max | cut -d '=' -f 2
r.mapcalc “newrast = myrast*100/$MAX”

On 04/25/2013 05:22 PM, simogeo wrote:

Hi,

I'm able to get the max value of a raster map using the following command :

which return max = 45784578
and I use this value to create another raster like so :

Returns :

which appears to be correct

My question is : Is there a way to do it dynamically? I want to automatise
that into a bash script.

I've tried : /r.mapcalc "newrast = myrast * 100 / max(myrast)"/ expecting
max(myrast) returns here 45784578 (max value) with no success.

returns : 

which appears to be incorrect.

Any help would be appreciated.

Thanks,
simon

--
View this message in context: [http://osgeo-org.1560.x6.nabble.com/r-mapcalc-and-us-of-max-value-tp5049643.html](http://osgeo-org.1560.x6.nabble.com/r-mapcalc-and-us-of-max-value-tp5049643.html)
Sent from the Grass - Users mailing list archive at Nabble.com.
_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[http://lists.osgeo.org/mailman/listinfo/grass-user](http://lists.osgeo.org/mailman/listinfo/grass-user)

This mail was received via Mail-SeCure System.

-- 
Micha Silver
GIS Consultant, Arava Development Co.
[http://www.surfaces.co.il](http://www.surfaces.co.il)

Hi Micha,

Thanks for your reply. It works perfectly but I would prefer to use :

since it's much faster!

thanks again.

Bye

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/r-mapcalc-and-us-of-max-value-tp5049643p5049720.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On Thu, Apr 25, 2013 at 10:08 PM, simogeo <simon.georget@gmail.com> wrote:

Hi Micha,

Thanks for your reply. It works perfectly but I would prefer to use :

MAX=`r.info -rst map=<your raster> | grep max | cut -d '=' -f 2`

r.info reports max of the raster map as it is, r.univar reports max
for the current region settings. Since r.mapcalc uses the current
region settings, you should really use r.univar instead of r.info.

Markus M

since it's much faster!

thanks again.

Bye

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/r-mapcalc-and-us-of-max-value-tp5049643p5049720.html
Sent from the Grass - Users mailing list archive at Nabble.com.
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

simogeo wrote:

I'm able to get the max value of a raster map using the
following command :

which return max = 45784578
and I use this value to create another raster like so :

Returns :

which appears to be correct

Hi,

please post in plain text, as often the HTML gets lost along
the way, many people don't get to see what you wrote, and the
archives don't either:
http://lists.osgeo.org/pipermail/grass-user/2013-April/067939.html
http://thread.gmane.org/gmane.comp.gis.grass.user/47096

thanks,
Hamish

On Thu, Apr 25, 2013 at 6:27 PM, Micha Silver <micha@arava.co.il> wrote:

MAX=`r.univar -g map=<your raster> | grep max | cut -d '=' -f 2`
r.mapcalc "newrast = myrast*100/$MAX"

Even easier:

GRASS 6.4.3svn (nc_spm_08):~ > eval `r.univar -g elevation`
GRASS 6.4.3svn (nc_spm_08):~ > echo $max
156.329864501953
GRASS 6.4.3svn (nc_spm_08):~ > r.mapcalc "newrast = myrast * 100.0 / $max"

Note that I wrote 100.0 for floating point arithmetics.

If you really want r.info, then likewise with:

GRASS 6.4.3svn (nc_spm_08):~ > eval `r.info -gr elevation`

markusN

Thanks for the precision. My current region is set using the raster map.

···

On Fri, Apr 26, 2013 at 10:29 AM, Markus Neteler <neteler@osgeo.org> wrote:

GRASS 6.4.3svn (nc_spm_08):~ > eval r.univar -g elevation
GRASS 6.4.3svn (nc_spm_08):~ > echo $max
156.329864501953
GRASS 6.4.3svn (nc_spm_08):~ > r.mapcalc “newrast = myrast * 100.0 / $max”

Note that I wrote 100.0 for floating point arithmetics.

If you really want r.info, then likewise with:

GRASS 6.4.3svn (nc_spm_08):~ > eval [r.info](http://r.info) -gr elevation

markusN

Nice alternative, indeed.

Thanks to all of you