Extract the number of planning units in an object.
Usage
number_of_planning_units(x, ...)
# S3 method for ConservationProblem
number_of_planning_units(x, ...)
# S3 method for OptimizationProblem
number_of_planning_units(x, ...)
Arguments
- x
problem()
oroptimization_problem()
object.- ...
not used.
Details
The planning units for an object corresponds to the number
of entries (e.g., rows, cells) for the planning unit data that
do not have missing (NA
) values for every zone.
For example, a single-layer raster dataset might have 90 cells
and only two of these cells contain non-missing (NA
) values.
As such, this dataset would have two planning units.
Examples
# \dontrun{
# load data
sim_pu_raster <- get_sim_pu_raster()
sim_features <- get_sim_features()
# create problem
p <-
problem(sim_pu_raster, sim_features) %>%
add_min_set_objective() %>%
add_relative_targets(0.2) %>%
add_binary_decisions()
# print number of planning units
print(number_of_planning_units(p))
#> [1] 90
# }