Learn R Programming

raptr (version 0.0.1)

RapData: Create new RapData object

Description

This function creates a "RapData" object using pre-processed data.

Usage

RapData(pu, species, targets, pu.species.probabilities, attribute.spaces, boundary, polygons = NA, skipchecks = FALSE, .cache = new.env())

Arguments

pu
data.frame planning unit data. Columns are 'cost' (numeric), 'area' (numeric), and 'status' (integer).
species
data.frame with species data. Columns are 'name' (character).
targets
data.frame with species data. Columns are 'species' (integer), 'target' (integer), 'proportion' (numeric).
pu.species.probabilities
data.frame with data on the probability of species in each planning unit. Columns are 'species' (integer), 'pu' (integer), and 'value' (numeric) columns.
attribute.spaces
list of AttributeSpaces objects with the demand points and planning unit coordinates.
boundary
data.frame with data on the shared boundary length of planning units. Columns are with 'id1' (integer), 'id2' (integer), and 'boundary' (integer).
polygons
PolySet planning unit spatial data or NULL if data not available.
skipchecks
logical Skip data integrity checks? May improve speed for big data sets.
.cache
environment used to cache calculations.

Value

RapData object

See Also

PolySet, SpatialPoints, SpatialPointsDataFrame, make.RapData, RapData-class.

Examples

Run this code
## Not run: 
# # load data
# data(cs_pus, cs_spp, cs_space)
# # create data for RapData object
# attribute.spaces <- list(
# 	AttributeSpaces(
# 	list(
# 			AttributeSpace(
# 			planning.unit.points=PlanningUnitPoints(
# 				rgeos::gCentroid(cs_pus[1:10,], byid=TRUE)@coords,
# 				seq_len(10)
# 			)
# 				demand.points=make.DemandPoints(
# 				SpatialPoints(
# 					coords=randomPoints(
# 						cs_spp,
# 						n=10,
# 						prob=TRUE
# 					)
# 				),
# 			),
# 			species=1L
# 		),
# 			AttributeSpace(
# 				planning.unit.points=PlanningUnitPoints(
# 				extract(cs_space[[1]],cs_pus[1:10,],fun=mean),
# 				seq_len(10)
# 			),
# 				demand.points=make.DemandPoints(
# 				SpatialPoints(
# 					coords=randomPoints(
# 						cs_spp,
# 						n=10,
# 						prob=TRUE
# 					)
# 				),
# 				cs_space[[1]]
# 			),
# 			species=1L
# 		)
# 		)
# 	)
# )
# pu.species.probabilities <- calcSpeciesAverageInPus(cs_pus[1:10,], cs_spp)
# polygons <- SpatialPolygons2PolySet(cs_pus[1:10,])
# boundary <- calcBoundaryData(cs_pus[1:10,])
# 
# x<-RapData(
# 	pu=cs_pus@data[1:10,],
# 	species=data.frame(name='test'),
#  target=data.frame(species=1, target=0:2, proportion=0.2),
# 	pu.species.probabilities=pu.species.probabilities,
# 	attribute.spaces=attribute.spaces,
# 	polygons=polygons,
# 	boundary=boundary
# )
# print(x)
# ## End(Not run)

Run the code above in your browser using DataLab