Big Data 8 min read

Using the TransBigData Python Library for Mobile Signaling Data Processing, Analysis, and Visualization

This article introduces the open‑source Python package TransBigData, explains how to install it, and demonstrates step‑by‑step methods for reading mobile signaling data, preprocessing, identifying stays and moves, extracting home and work locations, and visualizing individual activity patterns using Jupyter notebooks.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Using the TransBigData Python Library for Mobile Signaling Data Processing, Analysis, and Visualization

The author, based on the book "Transportation Spatiotemporal Big Data Analysis, Mining and Visualization," developed the open‑source Python library TransBigData to process, analyze, and visualize mobile signaling data.

TransBigData Overview

TransBigData is a Python package designed for handling common transportation spatiotemporal datasets such as taxi GPS, shared‑bike, and bus GPS data, providing fast and concise methods for preprocessing, gridding, visualization, trajectory handling, map basemap loading, coordinate conversion, and specialized processing like extracting order start/end points or identifying home/work locations.

Install the library via pip or conda:

<code>pip install -U transbigdata</code>

After installation, import the package in Python:

<code>import transbigdata as tbd</code>

Reading Mobile Signaling Data

Mobile signaling data, which records interactions between phones and base stations, can be read using pandas and then processed with TransBigData. Example code reads a CSV file, converts the time column to datetime, sorts the data, and displays the first rows:

<code>import pandas as pd
import transbigdata as tbd
data = pd.read_csv(r'data/mobiledata_sample.csv')
# Ensure the time column is correctly recognized (very important)
data['stime'] = pd.to_datetime(data['stime'], format='%Y%m%d%H%M')
data = data.sort_values(by=['user_id', 'stime'])
data.head()</code>

Identifying Stay and Move

Using tbd.mobile_stay_move , the data are first rasterized to a grid to reduce location noise, then stays and moves are extracted:

<code># Get grid parameters
params = tbd.area_to_params([121.860, 29.295, 121.862, 29.301], accuracy=500)
# Identify stays and moves
stay, move = tbd.mobile_stay_move(data, params, col=['user_id', 'stime', 'longitude', 'latitude'])</code>

Identifying Home and Work Locations

Home locations are identified as the longest nighttime stay, while work locations are the longest daytime stay on weekdays. The library provides tbd.mobile_identify_home and tbd.mobile_identify_work for this purpose.

<code># Identify home locations
home = tbd.mobile_identify_home(stay, col=['user_id','stime','etime','LONCOL','LATCOL','lon','lat'], start_hour=8, end_hour=20)
home.head()

# Identify work locations
work = tbd.mobile_identify_work(stay, col=['user_id','stime','etime','LONCOL','LATCOL','lon','lat'], minhour=3, start_hour=8, end_hour=20, workdaystart=0, workdayend=4)
work.head()</code>

Plotting Activity Maps

The function tbd.mobile_plot_activity visualizes daily activity for a specific user, with different colors representing different stay periods. Example code plots the activity of a user identified by its ID:

<code># Plot activity for a single user
uid = 'fcc3a9e9df361667e00ee5c16cb08922'
tbd.mobile_plot_activity(stay[stay['user_id']==uid], figsize=(20,5))</code>

The resulting plot shows each day's activity timeline, making it easy to see the start and end times of each stay.

Big DataPythondata analysisgeospatialMobile DataTransBigData
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.