Group polygon observations together into a 'genet' based on proximity
Source:R/groupByGenet.R
groupByGenet.Rd
This function assigns a unique 'genetID' to polygons if they are within a user-defined distance from one another. Each ramet is still represented by a single row of data, but all ramets of the same genet have the same 'genetID'.
Arguments
- dat
An sf object that contains polygons to be grouped. Typically should include data only for one species, one quadrat, and one year. For intended use, this dataset should be of the format described in
grasslandData
. This function will run if 'dat' contains only 'geometry' data, but it is strongly recommended that other columns specified ingrasslandData
are included.- buffGenet
A numeric argument indicating half of the maximum distance between individual ramets (polygons) that the function will group together as one genet. Note that this argument is in the same units that are used in the 'dat' argument. For example, if buffGenet = 0.005 and we use the
grasslandData
(in which measurements are in meters), then polygons that are 0.01 m (1 cm) apart or less will be grouped as a genet.- ...
Other arguments passed on to methods. Not currently used.
Value
A numeric vector of unique genetIDs that is as long as the number of
rows in 'dat.' Each element i
in the output is the genetID for the
i
th row in 'dat'.
Details
If polygons are 'grouped,' they are given the same number in the
'genetID' column. This assignment is made using network analysis to group
together polygons that are closest to one another. In the context of
plantTracker, this function was designed to group ramets (vegetative
clones) together into one genet (genetically distinct individual). This
function was designed for use within the assign
function (and
then the trackSpp
function), but can be used independently.
See also
assign()
and trackSpp()
, plantTracker functions that apply
this function across multiple species, quadrats, and years.
Examples
dat <- grasslandData[grasslandData$Site == "AZ" &
grasslandData$Quad == "SG2" &
grasslandData$Species == "Bouteloua rothrockii" &
grasslandData$Year == 1922,]
groupByGenet(dat = dat, buffGenet = 0.01)
#> [1] 1 2 3 4 5 6 7 8 9 10 11
groupByGenet(dat = dat, buffGenet = 0.1)
#> [1] 1 2 3 4 5 5 5 2 2 6 2