Skip to content

caesar0301/movr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

movr πŸ“Š

CRAN status R-CMD-check License: MIT DOI

Analyzing and Visualizing Human Mobility Data in R

movr is an R package that provides comprehensive tools for analyzing and visualizing spatio-temporal human mobility data. It originates from research on human mobility patterns and offers general transformation, calculation, and visualization utilities for mobility analysis.

Operating System Support

movr supports Linux, macOS, and Windows systems.

  • βœ… Linux: Ubuntu, Debian, and other Linux distributions
  • βœ… macOS: All macOS versions (tested on recent releases)
  • βœ… Windows: Native Windows support (Windows 10/11)
  • πŸ”„ Windows via WSL: Also supported through Windows Subsystem for Linux

Note: We have tested the package on Ubuntu, macOS, and Windows systems. Windows builds require system dependencies that are automatically handled during installation.

🌟 Features

  • 3D Trajectory Visualization: Interactive 3D plots of mobility trajectories
  • Flow Maps: Visualize population movements and migration patterns
  • Spatial Analysis: Voronoi tessellation, spatial correlation, and coverage analysis
  • Temporal Analysis: Time-of-day patterns, session generation, and temporal entropy
  • Statistical Tools: Radius of gyration, entropy measures, and predictability analysis
  • Data Quality: Comprehensive data quality assessment and validation tools

πŸ“¦ Installation

From GitHub

# Install devtools if you haven't already
if (!requireNamespace("devtools", quietly = TRUE)) {
  install.packages("devtools")
}

# Install movr from GitHub
devtools::install_github("caesar0301/movr")

System Requirements

  • R >= 3.0.0
  • GNU CMake (for building C extensions)
  • GLib development libraries

Ubuntu/Debian

sudo apt-get install cmake build-essential libglib2.0-dev

macOS

brew install cmake glib

Windows

Windows builds are now natively supported! The required dependencies are automatically installed during package installation. If you encounter issues, you can manually install:

  • Rtools: Download from CRAN
  • Optional: For advanced builds, install MSYS2 for additional Unix-like tools

Windows (via WSL)

Alternatively, you can use Windows Subsystem for Linux (WSL):

  1. Install WSL with Ubuntu from Microsoft Store
  2. Follow the Ubuntu/Debian installation instructions above

πŸš€ Quick Start

# Load the package
library(movr)

# Load example data
data(movement)

# Basic trajectory visualization
plot_traj3d(movement, x = "lon", y = "lat", z = "timestamp")

# Create a flow map
flowmap_data <- flowmap(movement, from = "origin", to = "destination")
plot_flowmap(flowmap_data)

πŸ“Š Usage Examples & Visualizations

3D Trajectory Visualization

Visualize individual or group mobility patterns in 3D space:

# 3D trajectory plot
plot_traj3d(movement, 
            x = "lon", y = "lat", z = "timestamp",
            color_by = "user_id",
            alpha = 0.7)

# Voronoi tessellation in 3D
voronoi_result <- voronoi3d(movement, x = "lon", y = "lat", z = "timestamp")

3D Trajectories

Flow Maps

Analyze population movements and migration patterns:

# Create flow map from mobility data
flow_data <- flowmap(movement, 
                     from = "origin_cell", 
                     to = "destination_cell",
                     weight = "flow_count")

# Visualize with custom styling
plot_flowmap(flow_data,
             node_size = "population",
             edge_width = "flow_strength",
             color_scheme = "viridis")

Flow Maps

Spatial Analysis

# Calculate radius of gyration
rog <- radius_of_gyration(movement, 
                         x = "lon", y = "lat", 
                         id = "user_id")

# Spatial correlation analysis
spatial_corr <- spatial.corr(movement, 
                            x = "lon", y = "lat",
                            time_window = "daily")

Temporal Analysis

# Time-of-day analysis
tod_data <- hour2tod(movement$timestamp)

# Generate mobility sessions
sessions <- gen_sessions(movement, 
                        id = "user_id",
                        time_threshold = 3600)  # 1 hour

# Calculate temporal entropy
temp_entropy <- entropy.spacetime(movement,
                                 id = "user_id",
                                 time_bins = 24)

Data Quality Assessment

# Comprehensive data quality check
dq_result <- dq.traj(movement,
                     id = "user_id",
                     time = "timestamp",
                     x = "lon", y = "lat")

# Point-level quality assessment
point_quality <- dq.point(movement,
                         x = "lon", y = "lat",
                         time = "timestamp")

3D Map Layers

# Create interactive 3D map visualizations
map3d_result <- map3d(movement, 
                      x = "lon", y = "lat", z = "timestamp",
                      terrain = TRUE,
                      buildings = TRUE)

3D Maps

πŸ“š Documentation

  • Vignettes: Comprehensive tutorials and examples
  • Function Reference: Complete API documentation
  • Examples: Code examples for common use cases
# View package vignettes
vignette(package = "movr")

# Get help for specific functions
?plot_traj3d
?flowmap
?radius_of_gyration

πŸ”¬ Potential Applications

movr is designed to support various research and practical applications in mobility analysis:

  • Urban Planning & Transportation: Analyze commuting patterns, traffic flows, and city dynamics
  • Epidemiology & Public Health: Model human mobility for disease spread prediction and contact tracing
  • Telecommunications: Optimize network infrastructure based on population movement patterns
  • Environmental Studies: Track animal migration patterns and habitat usage
  • Social Sciences: Study human behavior patterns and social interactions
  • Business Intelligence: Analyze customer movement patterns and location-based services
  • Emergency Response: Model evacuation patterns and emergency service optimization

Citation

If you use movr in your research, please cite:

@article{CHEN2017464,
  author = {Xiaming Chen and Haiyang Wang and Siwei Qiang and Yongkun Wang and Yaohui Jin},
  title = {Discovering and modeling meta-structures in human behavior from city-scale cellular data},
  journal = {Pervasive and Mobile Computing},
  volume = {40},
  pages = {464--476},
  year = {2017},
  doi = {https://doi.org/10.1016/j.pmcj.2017.02.001},
  url = {https://www.sciencedirect.com/science/article/pii/S1574119217300743}
}

πŸ› Bug Reports & Support

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • D4D Challenge: Mobile data from Senegal provided by Orange
  • R Community: For excellent tools and packages
  • Contributors: All those who have contributed to this project

Behavior informatics studies the intrinsic laws of human and animal behavior in nature. Insights into individual or group mobility dynamics facilitate the development of enhanced simulation and prediction models in application fields like wireless communication networks, animal migration, and epidemic prediction. In common scenarios, individual mobility is described by three-element tuples: <subjectId, timestamp, location>, where location is represented by symbolic character names or geo-coordinates. movr originates from research on human mobility and provides general transformation, calculation, and visualization tools to facilitate work in this area.