Extract the number of zones in an object.

number_of_zones(x)

# S4 method for ConservationProblem
number_of_zones(x)

# S4 method for OptimizationProblem
number_of_zones(x)

# S4 method for ZonesRaster
number_of_zones(x)

# S4 method for ZonesCharacter
number_of_zones(x)

Arguments

x

problem() (i.e. ConservationProblem), OptimizationProblem, or Zones() object.

Value

integer number of zones.

Examples

# load data
data(sim_pu_zones_stack, sim_features_zones)

# print number of zones in a Zones object
print(number_of_zones(sim_features_zones))
#> [1] 3
# create problem with multiple zones
p <- problem(sim_pu_zones_stack, sim_features_zones) %>%
     add_min_set_objective() %>%
     add_relative_targets(matrix(0.2, ncol = 3, nrow = 5)) %>%
     add_binary_decisions()

# print number of zones in the problem
print(number_of_zones(p))
#> [1] 3