gridcentroid: Calculate Stay Points

View source: R/gridcentroid.R

gridcentroidR Documentation

Calculate Stay Points

Description

This function identifies latent stay points based on spatial locations of stay events. A spatial grid with adjustable cell sizes is overlaid on stay events and the centroid of all the stay events fallen with one grid is considered a stay point. All the stay events are viewed as visits to the stay point.

Usage

gridcentroid(
  df,
  coor = NULL,
  cell.size = NULL,
  cell.units = "meters",
  point.id = NULL,
  group.id = NULL
)

Arguments

df

a data frame object.

coor

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

cell.size

size of the the spatial grid to overlay with spatial points.

cell.units

unit of the cell size length. It has to be meters.

point.id

id of the input spatial points.

Value

a data frame with three new columns added showing stay points and locations.

Note

gridcentroid function can be slow if the spatial points are scattered in a large area and grid size is small. It is recommended to run in small batches.

References

Toole, J.L., et al. The path most traveled: Travel demand estimation using big data resources. Transport. Res. Part C (2015), http://dx.doi.org/10.1016/j.trc.2015.04.022

See Also

stayevents

Examples

data(mobility)
mobility_stay<- stayevent(mobility, coor = c("lon","lat"), time = "datetime", dist.threshold = 100,
                 time.threshold = 30, time.units = "mins", groupvar = "id")


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