[GRASS-user] Uniform random raster

Paulo van Breugel p.vanbreugel at gmail.com
Tue Feb 16 00:47:50 PST 2016



On 16-02-16 05:04, Thomas Adams wrote:
> Giuseppe,
>
> Unless I have misunderstood, in GRASS use r.mapcalc...
>
> First set you region for your area of interest, for example:
>
> g.region -dp e=2614612.5 w=1423987.5 n=-4624387.5 s=-5862637.5
>
> Then:
> r.mapcalc expression="outputMap=25.4"
>
> where 25.4 is your value of interest, and finally:
>
> r.out.gdal input=outputMap output=outputFileName format=GTiff
>
> Best,
> Tom
>
> On Mon, Feb 15, 2016 at 9:33 PM, Giuseppe Amatulli 
> <giuseppe.amatulli at gmail.com <mailto:giuseppe.amatulli at gmail.com>> wrote:
>
>     Hi,
>     I would like to create an uniform random raster, similar to what i
>     would obtain in R with the following code
>
>     raster=raster(matrix(runif(54210, max=50, min=-50, 139,390) ,
>     ...........)
>     writeRaster(raster,filename=random.tif",formats=GTiff,overwrite=TRUE)
>
>     I read the explanation of
>     https://grass.osgeo.org/grass7/manuals/r.random.surface.html
>     and also r.mapcalc - random (a,b)
>     but I'm not sure if one of them produce the same concept/result.
>

That function creates random surface(s) with spatial dependence (there 
is a small typo in the link, it should be grass70). What you want, I 
think, is the r.surf.random function 
(https://grass.osgeo.org/grass70/manuals/r.surf.random.html). The 
r.mapcalc - random(a,b) should also do what you want, it also gives a 
uniform distribution.

p.s. some of the brackets in your R code above are off, it should 
probably be something like raster=raster(matrix(runif(54210, max=50, 
min=-50), 139,390) , ...........). Like Thomas wrote, in GRASS you first 
need to define your region and set your resolution (check out g.region 
for all settings, including the option to set number of rows and 
columns). Than you can run r.surf.random or r.mapcalc to generate your 
new random surface layer.

>
>     Any input? or better explanation
>
>     Thanks
>     Best
>     Giuseppe
>
>     -- 
>     Giuseppe Amatulli, Ph.D.
>
>     Department of Ecology and Evolutionary Biology, Yale University.
>     Jetz Lab, OML Room 405
>     P.O. Box 208106
>     165 PROSPECT ST
>     New Haven, CT 06520-8106
>     Teaching: spatial-ecology.net <http://spatial-ecology.net>
>     Work: http://sbsc.yale.edu/giuseppe-amatulli
>
>     _______________________________________________
>     grass-user mailing list
>     grass-user at lists.osgeo.org <mailto:grass-user at lists.osgeo.org>
>     http://lists.osgeo.org/mailman/listinfo/grass-user
>
>
>
>
> -- 
> Thomas E Adams, III
> 2330 Jack Warner PKWY, #334
> Tuscaloosa, AL 35401
>
> 1 (513) 739-9512 (cell)
>
>
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20160216/eefd628a/attachment-0001.html>


More information about the grass-user mailing list