number_of_planning_units: Number of planning units

View source: R/number_of_planning_units.R

number_of_planning_unitsR Documentation

Number of planning units

Description

Extract the number of planning units in an object.

Usage

number_of_planning_units(x, ...)

## S3 method for class 'ConservationProblem'
number_of_planning_units(x, ...)

## S3 method for class 'OptimizationProblem'
number_of_planning_units(x, ...)

Arguments

x

problem() or optimization_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.

Value

An integer number of planning units.

Examples

## Not run: 
# 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))

## End(Not run)

prioritizr/prioritizr documentation built on March 4, 2024, 3:54 p.m.