displacement: Calculate Displacement of Spatial Locations

View source: R/displacement.R

displacementR Documentation

Calculate Displacement of Spatial Locations

Description

This function calculates the distance between two consecutive stay events using their geolocations.

Usage

displacement(df, coor = NULL, groupvar = NULL)

Arguments

df

a data frame object.

coor

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

groupvar

grouping object to stratify time objects. Recommend to be ID for each individual. If groupvar is not specified, the entire data frame will be considered as one group to calculate displacement.

Value

a list of distance values. Unit is meters.

See Also

slide

Examples

data(mobility)
mobility_stay<- stayevent(mobility, coor = c("lon","lat"), time = "datetime", dist.threshold = 100,
time.threshold = 30, time.units = "mins", groupvar = "id")
mobility_stay<- aggregate(cbind(id, stayeventlon, stayeventlat)~stayeventgroup, mobility_stay, mean)
mobility_stay$dispm<- displacement(mobility_stay, coor = c("stayeventlon","stayeventlat"), groupvar = "id")


nyu-mhealth/Mobility documentation built on July 4, 2025, 9:54 a.m.