df2brick: Convert a XYZ-layer data frame to a raster brick

View source: R/df2brick.R

df2brickR Documentation

Convert a XYZ-layer data frame to a raster brick

Description

Converts a XYZ-layer data frame to a raster brick.

Usage

df2brick(df, x_col, y_col, z_col, layer_col)

Arguments

df

A dataframe with XYZ info for many layers

x_col

Name of the column with the x info

y_col

Name of the column with the y info

z_col

Name of the column with the z info

layer_col

Name of the column with the layer info

Value

A raster brick

Examples

nlayers <- 10
df <- expand.grid(layer=1:nlayers, x=1:10, y=1:10) %>%
  arrange(layer) %>%
  mutate(z=runif(n=n()))
df_brick <- df2brick(df=df, x_col="x", y_col="y", z_col="z", layer_col="layer")
raster::plot(df_brick)

cfree14/freeR documentation built on Aug. 22, 2023, 11:12 p.m.