% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/runifRast.r
\name{rUnifRast,GRaster-method}
\alias{rUnifRast,GRaster-method}
\alias{rUnifRast}
\title{Create a raster with random values drawn from a uniform distribution}
\usage{
\S4method{rUnifRast}{GRaster}(x, n = 1, low = 0, high = 1, seed = NULL)
}
\arguments{
\item{x}{A \code{GRaster}. The output will have the same extent and dimensions as this raster.}

\item{n}{A numeric integer: Number of rasters to generate.}

\item{low, high}{Numeric: Minimum and maximum values from which to select.}

\item{seed}{Numeric integer vector or \code{NULL}: Random seed. If \code{NULL}, then a different seed will be generated by \strong{GRASS}. Defining this is useful if you want to recreate rasters.  If provided, there should be one seed value per raster.}
}
\value{
A \code{GRaster}.
}
\description{
\code{rUnifRast()} creates a raster with values drawn from a uniform (flat) distribution.
}
\examples{
if (grassStarted()) {

# Setup
library(sf)
library(terra)

# Elevation raster
madElev <- fastData("madElev")

# Convert a SpatRaster to a GRaster:
elev <- fast(madElev)

### Create a raster with values drawn from a uniform distribution:
unif <- rUnifRast(elev)
plot(unif)

### Create a raster with values drawn from a normal distribution:
norms <- rNormRast(elev, n = 2, mu = c(5, 10), sigma = c(2, 1))
plot(norms)
hist(norms, bins = 100)

# Create a raster with random, seemingly normally-distributed values:
rand <- rSpatialDepRast(elev, dist = 1000)
plot(rand)

# Values appear normal on first inspection:
hist(rand)

# ... but actually are patterned:
hist(rand, bins = 100)

# Create a fractal raster:
fractal <- fractalRast(elev, n = 2, dimension = c(2.1, 2.8))
plot(fractal)
hist(fractal)

### Random walker rasters

# One random walker
walk <- rWalkRast(elev)
plot(walk)

# Random walker with self-avoidance:
walkAvoid <- rWalkRast(elev, steps = 1000, avoid = TRUE, seed = 1)
plot(walkAvoid)

# 10 random walkers:
walk10 <- rWalkRast(elev, n = 10)
plot(walk10)

# 10 random walkers starting in same place:
walkSame10 <- rWalkRast(elev, n = 10, sameStart = TRUE)
plot(walkSame10)


}
}
\seealso{
\code{\link[=rNormRast]{rNormRast()}}, \code{\link[=rSpatialDepRast]{rSpatialDepRast()}}, \code{\link[=fractalRast]{fractalRast()}}, \code{\link[=rWalkRast]{rWalkRast()}}, \strong{GRASS} manual page for tool \code{r.random.surface} (see \code{grassHelp("r.random.surface")})
}
