spatsoc is an R package for detecting spatial and temporal groups in GPS relocations.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Dockerfiles
R
inst
man
tests
vignettes
.Rbuildignore
.gitignore
.gitlab-ci.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
DESCRIPTION
LICENSE
Makefile
NAMESPACE
NEWS.md
README.Rmd
README.md
_pkgdown.yml
codemeta.json
cran-comments.md
spatsoc.Rproj

README.md

Project Status: Active – The project has reached a stable, usable state and is being actively developed. develVersion CRAN codecov pipeline status

spatsoc

spatsoc is an R package for detecting spatial and temporal groups in GPS relocations. It can be used to convert GPS relocations to gambit-of-the-group format to build proximity-based social networks. In addition, the randomizations function provides data-stream randomization methods suitable for GPS data and the get_gbi function generates group by individual matrices useful for building networks with asnipe::get_network.

See below for installation and basic usage.

For more details, see the blog post and vignettes:

Installation

Install the latest version with remotes.

remotes::install_github('ropensci/spatsoc')

# or CRAN
install.packages('spatsoc')

spatsoc depends on rgeos and requires GEOS installed on the system.

  • Debian/Ubuntu: apt-get install libgeos-dev
  • Arch: pacman -S geos
  • Fedora: dnf install geos geos-devel
  • Mac: brew install geos
  • Windows: see here

Usage

Import package, read data

spatsoc expects a data.table for all of its functions. If you have a data.frame, you can use data.table::setDT() to convert it by reference. If your data is a text file (e.g.: CSV), you can use data.table::fread() to import it as a data.table.

library(spatsoc)
library(data.table)
DT <- fread(system.file("extdata", "DT.csv", package = "spatsoc"))
DT[, datetime := as.POSIXct(datetime, tz = 'UTC')]

Temporal grouping

group_times

group_times(
  DT, 
  datetime = 'datetime', 
  threshold = '5 minutes'
)

Spatial grouping

group_pts

group_pts(
  DT,
  threshold = 5,
  id = 'ID',
  coords = c('X', 'Y'),
  timegroup = 'timegroup'
)

group_lines

utm <-
  '+proj=utm +zone=36 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
  
group_times(
  DT, 
  datetime = 'datetime', 
  threshold = '1 day'
)

group_lines(
  DT,
  threshold = 50,
  projection = utm,
  id = 'ID',
  coords = c('X', 'Y'),
  timegroup = 'timegroup',
  sortBy = 'datetime'
)

group_polys

utm <- '+proj=utm +zone=36 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs'

group_polys(
  DT,
  area = FALSE,
  'mcp',
  list(percent = 95),
  projection = utm,
  id = 'ID',
  coords = c('X', 'Y')
)
  
areaDT <- group_polys(
  DT,
  area = TRUE,
  'mcp',
  list(percent = 95),
  projection = utm,
  id = 'ID',
  coords = c('X', 'Y')
)

Contributing

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Development of spatsoc welcomes contribution of feature requests, bug reports and suggested improvements through the issue board.

See details in CONTRIBUTING.md.

ropensci_footer