Make an overlay for an OrganizedBirds object and a grid to identify which observations that fall into which grid cell.

overlayBirds(x, grid, spillOver = NULL, cleanGrid = TRUE)

# S3 method for OrganizedBirds
overlayBirds(x, grid, spillOver = NULL, cleanGrid = TRUE)

Arguments

x

An OrganizedBirds object

grid

A sf or SpatialPolygonsDataFrame object of the grid over the study area

spillOver

Specifies if the function should search for observations with the same visitUID over several grid cell, and what to do with them. It accepts c(NULL, "unique", "duplicate"). Default NULL.

cleanGrid

logical. Whether to remove all data from the grid.

Value

The output is a OverlaidBirds-class object, which is a list containing three objects;

observationsInGrid

Is basically the data in the OrganizedBirds object split by each grid cell (n.b. the use of spillOver discussed under "Usage")

grid

The sf from the input, optionally cleared of data

nonEmptyGridCells

An integer vector of which grid cells that have observations

Details

This function takes an OrganizedBirds object, created by organizeBirds, and a polygon grid-layer, which could be created by makeGrid and splits the visits in the OrganizedBirds (i.e. data belonging to identified visits) to each grid cell.

If spillOver = NULL the splitting is done spatially according to the overlay of observations and grid cells, without further consideration of coherence for visits (visit UID). If spillOver = c("unique", "duplicate") the splitting will be done spatially in a first step, and then: if (spillOver = "unique") assigns (and moves) all observations with same visitUID to the grid cell with most observations (or picks one grid cell at random if there is a tie); or if (spillOver = "duplicate") duplicates all observations with same visitUID across all grid cells containing at least one observation with that visitUID.

The later approach is useful when the amount of observations spilled over neighbouring cells is minimal and information over the spatial extent of the sampling effort is more important than sample independence.

Examples

# \donttest{ ob <- organizeBirds(bombusObs) grid <- makeGrid(gotaland, 10) ovB <- overlayBirds(ob, grid)
#> 1340 observations did not overlap with the grid and will be discarded.
#> 0.03 % of the visits spill over neighbouring grid cells.
# }