Skip to main content
QUICK REVIEW

[Paper Review] Mining online social networks with Python to study urban mobility

Antònia Tugores, Pere Colet|arXiv (Cornell University)|Apr 25, 2014
Human Mobility and Location-Based AnalysisSocial Sciences4 citations
TL;DR

This paper presents a scalable Python-based pipeline for mining geolocated Twitter data using the Tweepy API and MongoDB noSQL database to study urban mobility patterns. By efficiently storing and querying over 850 million tweets, the system achieves sub-10 second response times for 70% of geo-spatial queries, enabling robust analysis of human mobility in cities like Barcelona and London.

ABSTRACT

On-line social networks have grown quickly over the last few years and nowadays many people use them frequently. Furthermore the emergence of smartphones allows to access these networks any time from any physical location. Among the social networks, Twitter offers a particularly large set of data publicly available. Here we discuss the procedure to mine this data and store it in distributed databases using Python scripts. We also illustrate how geolocated tweets can be used to study the mobility of people in urban areas.

Motivation & Objective

  • To develop an efficient, scalable method for acquiring and storing large volumes of geolocated social media data for urban mobility research.
  • To compare the performance of SQL and noSQL databases in handling high-velocity, high-volume tweet data streams.
  • To enable real-time analysis of human mobility patterns using spatial queries on distributed, geotagged tweet data.
  • To validate that long-term Twitter data sampling reflects actual urban population and transportation dynamics.
  • To support future urban planning and mobility modeling through integration of social network data with land use and transportation systems.

Proposed method

  • Utilizes Python scripts with the Tweepy library to access the Twitter API and collect tweets based on user location in target cities.
  • Employs MongoDB as a distributed, schema-free noSQL database to store tweets in JSON format, enabling horizontal scaling and high write throughput.
  • Applies 2d geospatial indexing on latitude and longitude fields to support efficient proximity queries despite limitations in early MongoDB versions.
  • Performs geoNear queries on a grid of one-mile spaced points across metropolitan areas to extract location-specific tweet densities.
  • Uses data partitioning across three shards (replica sets) to enhance insertion and query performance under high data volume.
  • Implements query routing to secondary nodes to decouple read and write operations, maintaining high insertion performance during active querying.

Experimental results

Research questions

  • RQ1Can geolocated Twitter data be efficiently acquired and stored at scale to support urban mobility analysis?
  • RQ2How does the performance of a distributed noSQL database (MongoDB) compare to a traditional SQL database (MySQL) for high-volume tweet ingestion and querying?
  • RQ3To what extent do long-term Twitter data samples reflect real urban population distributions and transportation network patterns?
  • RQ4What is the response time performance of spatial queries on a large-scale, distributed tweet database?
  • RQ5Can social media data be reliably used to model joint mobility behaviors and urban land use patterns in European cities?

Key findings

  • MongoDB achieved a 2x speedup in inserting 100,000 tweets compared to MySQL, with insertion times remaining stable as the database grew to 850 million documents.
  • The median response time for geoNear queries on a 1-mile radius was 3 seconds, and 70% of queries completed in under 9 seconds.
  • Despite occasional spikes exceeding 30 seconds, the system maintained acceptable performance for real-time mobility analysis under high load.
  • Ten months of Twitter data showed strong agreement with actual population distributions and transportation networks in Barcelona and London.
  • The use of 2d geospatial indexing on latitude and longitude enabled efficient spatial queries, though the 2dsphere index was not usable due to sparse data constraints in MongoDB 2.4.
  • The system successfully supported continuous data ingestion and querying by offloading read operations to secondary nodes, ensuring sustained write performance.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.