This function returns the unique values of an object.
Examples
landscape <- terra::rast(landscapemetrics::landscape)
get_unique_values(landscape)
#> Warning: Double values will be converted to integer.
#> $layer_1
#> [1] 1 2 3
#>
landscape_stack <- c(landscape, landscape, landscape)
get_unique_values(landscape_stack)
#> Warning: Double values will be converted to integer.
#> Warning: Double values will be converted to integer.
#> Warning: Double values will be converted to integer.
#> $layer_1
#> [1] 1 2 3
#>
#> $layer_2
#> [1] 1 2 3
#>
#> $layer_3
#> [1] 1 2 3
#>
landscape_matrix <- terra::as.matrix(landscape, wide = TRUE)
get_unique_values(landscape_matrix)
#> Warning: Double values will be converted to integer.
#> $layer_1
#> [1] 1 2 3
#>
x_vec <- c(1, 2, 1, 1, 2, 2)
get_unique_values(x_vec)
#> Warning: Double values will be converted to integer.
#> $layer_1
#> [1] 1 2
#>
landscape_list <- list(landscape, landscape_matrix, x_vec)
get_unique_values(landscape_list)
#> Warning: Double values will be converted to integer.
#> Warning: Double values will be converted to integer.
#> Warning: Double values will be converted to integer.
#> $layer_1
#> [1] 1 2 3
#>
#> $layer_2
#> [1] 1 2 3
#>
#> $layer_3
#> [1] 1 2
#>