fractalRast,GRaster-method | R Documentation |
fractalRast()
creates a raster with a fractal pattern.
## S4 method for signature 'GRaster'
fractalRast(x, n = 1, mu = 0, sigma = 1, dimension = 2.05)
x |
A |
n |
A numeric integer: Number of rasters to generate. |
mu , sigma |
Numeric: Mean and sample standard deviation of output. |
dimension |
Numeric: Fractal dimension. Must be between 2 and 3. |
A GRaster
.
rSpatialDepRast()
, rnormRast()
, runifRast()
, GRASS manual page for module r.surf.fractal
(see grassHelp("r.surf.fractal")
)
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.