Skip to contents

Provide a sf object with a POINT at each record corresponding to a trap location, specifying which variables contain the required information. Or define a set of traps without spatial coordinates. Or, extract the trap data used in a sit object.

Usage

sit_traps(x, ...)

# S3 method for sf
sit_traps(
  x,
  id = "id",
  type = "type",
  area = "area",
  label,
  trap_types = sit_trap_types(),
  ...
)

# S3 method for character
sit_traps(x, type, area, trap_types = sit_trap_types(), ...)

# S3 method for numeric
sit_traps(x, ...)

# S3 method for sit_traps
c(...)

# S3 method for sit
sit_traps(
  x,
  type = sit_trap_types(x)$label,
  stage = unique(sit_trap_types(x)$stage),
  area = unique(x$traps$area),
  ...
)

Arguments

x

Object of class sf with POINT elements to be imported, or a character-coerced vector trap codes to be defined, or an object of class sit to extract trap information from.

...

Used to pass arguments to specific method.

id

Character. Variable name with a custom code for the trap. Jointly with type, identifies the trap uniquely.

type

Character. Variable name with valid values of trap types (i.e., any of trap_types$label). For the extraction method, a character vector of trap types to filter upon.

area

Character. Variable name with values either control or sit. For the extraction method, a character vector of areas to filter upon.

label

Optional character. Variable name with custom text associated to the traps.

trap_types

Table of trap types, created with sit_trap_types().

stage

Character vector of stages (i.e., adult or egg) to filter upon extraction.

Value

A object of class sit_traps which can be used in sit().

Methods (by class)

  • sf: Imports spatialised trap data

  • character: Imports non-spatialised trap data

  • numeric: Imports non-spatialised trap data

  • sit_traps: Combine traps.

  • sit: Extracts trap data

See also

Examples


## Build spatialised traps from a `sf` object
traps_sf <- sf::st_as_sf(
  data.frame(
    x = 1:3,
    y = 3:1,
    "Trap.Id" = letters[1:3],
    Type = "BGS",
    area = "sit"
  ),
  coords = c("x", "y")
)
sit_traps(traps_sf, id = "Trap.Id", type = "Type", area = "area")
#> Simple feature collection with 3 features and 8 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 1 ymin: 1 xmax: 3 ymax: 3
#> CRS:           NA
#>   id code area label   type_name type_label type_stage type_description
#> 1  1    a  sit    NA BG-Sentinel        BGS      adult               NA
#> 2  2    b  sit    NA BG-Sentinel        BGS      adult               NA
#> 3  3    c  sit    NA BG-Sentinel        BGS      adult               NA
#>      geometry
#> 1 POINT (1 3)
#> 2 POINT (2 2)
#> 3 POINT (3 1)

## Build non-spatialised traps from a vector of codes
sit_traps(paste0("C", 1:5), area = 'control', type = 'OVT')
#> Simple feature collection with 5 features and 8 fields (with 5 geometries empty)
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: NA ymin: NA xmax: NA ymax: NA
#> CRS:           NA
#>   id code    area label type_name type_label type_stage
#> 1  1   C1 control    NA   Ovitrap        OVT        egg
#> 2  2   C2 control    NA   Ovitrap        OVT        egg
#> 3  3   C3 control    NA   Ovitrap        OVT        egg
#> 4  4   C4 control    NA   Ovitrap        OVT        egg
#> 5  5   C5 control    NA   Ovitrap        OVT        egg
#>   type_description    geometry
#> 1               NA POINT EMPTY
#> 2               NA POINT EMPTY
#> 3               NA POINT EMPTY
#> 4               NA POINT EMPTY
#> 5               NA POINT EMPTY

## Retrieve traps in a `sit` object
## sit_traps(sit_prototype)