Skip to contents

A function to create random multiclass data. This function allows you to create random spatial data for a specified number of classes (num_class) and replicates (num_rep)

Usage

generate_random_class(data, num_class, num_rep, return_sf = TRUE)

Arguments

data

Input extent of data 'sf', 'sp', or 'Vect'

num_class

number of required classes

num_rep

replication for each class

return_sf

(logical) if true returns 'sf' object using coordinate system of input data

Value

If 'return_sf' is TRUE, the function returns an 'sf' object containing the generated classes. If 'return_sf' is FALSE, the function returns a data frame containing the generated classes.

Examples

# Load sample data
data("landcover")

# Generate random classes with 5 classes and 100 replicates per class
samp_data <- generate_random_class(landcover, 5, 100,return_sf = FALSE)
head(samp_data)
#>          x       y class
#> 1 408683.6 3121155     1
#> 2 435521.3 3128639     1
#> 3 457853.5 3167238     1
#> 4 429557.9 3154871     1
#> 5 459663.1 3127548     1
#> 6 426685.8 3127122     1