Skip to contents

Extract the number of zones in an object.

Usage

number_of_zones(x, ...)

# S3 method for ConservationProblem
number_of_zones(x, ...)

# S3 method for OptimizationProblem
number_of_zones(x, ...)

# S3 method for ZonesRaster
number_of_zones(x, ...)

# S3 method for ZonesSpatRaster
number_of_zones(x, ...)

# S3 method for ZonesCharacter
number_of_zones(x, ...)

Arguments

x

problem(), optimization_problem(), or zones() object.

...

not used.

Value

An integer number of zones.

Examples

# \dontrun{
# load data
sim_zones_pu_raster <- get_sim_zones_pu_raster()
sim_zones_features <- get_sim_zones_features()

# print number of zones in a Zones object
print(number_of_zones(sim_zones_features))
#> [1] 3
# create problem with multiple zones
p <-
  problem(sim_zones_pu_raster, sim_zones_features) %>%
  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
# }