This function creates a "RapData" object using pre-processed data.
RapData(
pu,
species,
targets,
pu.species.probabilities,
attribute.spaces,
boundary,
polygons = NA,
skipchecks = FALSE,
.cache = new.env()
)
base::data.frame()
planning unit data. Columns must be
"cost" (numeric
), "area" (numeric
), and "status"
(integer
).
base::data.frame()
with species data. Columns
must be "name" (character
).
base::data.frame()
with species data.
Columns must be "species" (integer
), "target" (integer
),
"proportion" (numeric
).
base::data.frame()
with data on
the probability of species in each planning unit. Columns must be
"species", (integer
), "pu" (integer
), and "value"
(numeric
).
list
of AttributeSpaces()
objects
with the demand points and planning unit coordinates.
base::data.frame()
with data on the shared
boundary length of planning units. Columns must be "id1"
(integer
), "id2" (integer
), and "boundary" (integer
).
PBSmapping::PolySet()
planning unit spatial data
or NULL
if data not available.
logical
Skip data integrity checks? May improve
speed for big data sets.
base::environment()
used to cache calculations.
A new RapData
object.
Generally, users are not encouraged to change arguments to
.cache
.
# \dontrun{
# load data
cs_pus <- sf::read_sf(
system.file("extdata", "cs_pus.gpkg", package = "raptr")
)
cs_spp <- terra::rast(
system.file("extdata", "cs_spp.tif", package = "raptr")
)
cs_space <- terra::rast(
system.file("extdata", "cs_space.tif", package = "raptr")
)
# create data for RapData object
attribute.spaces <- list(
AttributeSpaces(name = "geographic", list(
AttributeSpace(
planning.unit.points = PlanningUnitPoints(
suppressWarnings(
sf::st_coordinates(sf::st_centroid(cs_pus[1:10, ]))
),
seq_len(10)
),
demand.points = make.DemandPoints(
randomPoints(cs_spp[[1]], n = 10, prob = TRUE)
),
species = 1L
))
),
AttributeSpaces(name = "environmental", list(
AttributeSpace(
planning.unit.points = PlanningUnitPoints(
as.matrix(terra::extract(
cs_space[[1]], as(cs_pus[1:10, ], "SpatVector"),
fun = "mean",
ID = FALSE
)),
seq_len(10)
),
demand.points = make.DemandPoints(
as.matrix(terra::as.data.frame(cs_space[[1]], na.rm = TRUE))
),
species = 1L
)
))
)
#> Registered S3 methods overwritten by 'adehabitatMA':
#> method from
#> print.SpatialPixelsDataFrame sp
#> print.SpatialPixels sp
pu.species.probabilities <- calcSpeciesAverageInPus(
cs_pus[1:10,], cs_spp[[1]]
)
polygons <- convert2PolySet(cs_pus[1:10, ])
boundary <- calcBoundaryData(cs_pus[1:10, ])
# create RapData object
x <- RapData(
pu = cs_pus[1:10, ], species = data.frame(name = "test"),
target = data.frame(species = 1L, target = 0:2, proportion = 0.2),
pu.species.probabilities = pu.species.probabilities,
attribute.spaces = attribute.spaces,
polygons = polygons,
boundary = boundary
)
# print object
print(x)
#> RapData object.
#> Number of planning units: 10
#> Number of species: 1
#> Number of attribute spaces: 2
# }