spdf2turtles: From 'SpatialPointsDataFrame' to 'agentMatrix'

spdf2turtlesR Documentation

From SpatialPointsDataFrame to agentMatrix

Description

Convert a SpatialPointsDataFrame object into an agentMatrix object.

Usage

spdf2turtles(spdf)

## S4 method for signature 'ANY'
spdf2turtles(spdf)

Arguments

spdf

SpatialPointsDataFrame object representing moving agents.

Details

If the spdf does not contain the variables created with createTurtles(), these variables will be created with the default values as in createTurtles().

Value

AgentMatrix object representing the moving agents (coordinates and data) as contained in spdf.

Author(s)

Sarah Bauduin

Examples

if (requireNamespace("sp", quietly = TRUE)) {
  sp1 <- sp::SpatialPointsDataFrame(
    coords = cbind(x = c(1, 2, 3), y = c(1, 2, 3)),
    data = cbind.data.frame(
      age = c(0, 0, 3),
      sex = c("F", "F", "M")
    )
  )
  t1 <- spdf2turtles(spdf = sp1)
}


PredictiveEcology/NetLogoR documentation built on Jan. 31, 2024, 9:31 p.m.