groupdist: Group Spatial Points by Distance

Description Usage Arguments Value See Also Examples

View source: R/groupdist.R

Description

This function groups spatial points based on the distance to the next point. If distance is smaller than a threshold, points are considered in the same group. Group number for points outside the threshold is NA. Depending on how many spatial points are in the data frame, runtime might be long.

Usage

1
groupdist(df, coor = NULL, threshold = NULL, groupvar = NULL)

Arguments

df

df a data frame object.

coor

longitude and latitude of the spatial points in the format of c("lon","lat").

threshold

a distance threshold used to determine if points are in the same group. The format is numeric. Unit is meters.

groupvar

grouping object to stratify spatial points. Recommend to be ID for each individual. If groupvar is not specified, all spatial points processed based on their original sequence.

Value

a list of numbers and NAs indicating whether a set of spatial points are in the same group or not in any groups.

See Also

seqgroup

Examples

1
2
data(mobility)
mobility$distgroup<- groupdist(mobility, coor = c("lon", "lat"), threshold = 100, groupvar = "id")

nyu-mhealth/Mobility documentation built on Feb. 24, 2020, 10:37 p.m.