Description Usage Arguments Details Value See Also Examples
Add constraints to ensure that they are prioritized in the solution. For example, it may be desirable to lock in planning units that are inside existing protected areas so that the solution fills in the gaps in the existing reserve network.
1 | add_locked_in_constraints(x, locked_in)
|
x |
|
locked_in |
Object that determines which planning units that should be locked in. See details for more information. |
The locked in planning units can be specified in several different ways:
integer
vector
of indices pertaining to which
planning units should be locked in.
character
column name in the attribute table values
indicating if planning units should be locked in. This option is
only available if the planning units in x
are a
Spatial-class
object. The column in the attribute
table should have logical
(ie. TRUE
or FALSE
)
values indicating if the planning unit is to be locked in.
Raster-class
objectplanning units in x
that intersect with cells in y
are locked in. Specifically,
only if the intersect with cells in y
are that are not equal to
zero or NA
.
Spatial-class
object.planning units in x
that spatially intersect with locked_in
are locked in.
ConservationProblem-class
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # create basic problem
p1 <- problem(sim_pu_polygons, sim_features) %>%
add_min_set_objective() %>%
add_relative_targets(0.2)
# create problem with added locked in constraints using integers
p2 <- p1 %>% add_locked_in_constraints(which(sim_pu_polygons$locked_in))
# create problem with added locked in constraints using a field name
p3 <- p1 %>% add_locked_in_constraints("locked_in")
# create problem with added locked in constraints using raster data
p4 <- p1 %>% add_locked_in_constraints(sim_locked_in_raster)
# create problem with added locked in constraints using spatial polygons data
locked_in <- sim_pu_polygons[sim_pu_polygons$locked_in == 1,]
p5 <- p1 %>% add_locked_in_constraints(locked_in)
# solve problems
s1 <- solve(p1)
s2 <- solve(p2)
s3 <- solve(p3)
s4 <- solve(p4)
s5 <- solve(p5)
# plot solutions
par(mfrow=c(3,2))
plot(s1, main="none locked in")
plot(s1[s1$solution==1,], col="darkgreen", add=TRUE)
plot(s2, main="locked in (integer input)")
plot(s2[s2$solution==1,], col="darkgreen", add=TRUE)
plot(s3, main="locked in (character input)")
plot(s3[s3$solution==1,], col="darkgreen", add=TRUE)
plot(s4, main="locked in (raster input)")
plot(s4[s4$solution==1,], col="darkgreen", add=TRUE)
plot(s5, main="locked in (polygon input)")
plot(s5[s5$solution==1,], col="darkgreen", add=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.