DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Scaling Cloud Data Automation: A Practical Guide to Open Table Formats
  • Ten Years of Beam: From Google's Dataflow Paper to 4 Trillion Events at LinkedIn
  • Data Processing for Real Estate: Enabling Smart Analysis and Decision-Making
  • Hadoop on AmpereOne Reference Architecture

Trending

  • Lambda-Driven API Design: Building Composable Node.js Endpoints With Functional Primitives
  • Why AI-Generated Code Breaks Your Testing Assumptions
  • When Snowflake Lies to You: Understanding False Failures in dbt Pipelines
  • Spring Boot Done Right: Lessons From a 400-Module Codebase
  1. DZone
  2. Data Engineering
  3. Data
  4. Real-Time Transit Feed Data Processing With Apache NiFi

Real-Time Transit Feed Data Processing With Apache NiFi

Ingesting and processing real-time transit feeds at scale with Apache NiFi.

By 
Tim Spann user avatar
Tim Spann
DZone Core CORE ·
Aug. 26, 19 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
14.1K Views

Join the DZone community and get the full member experience.

Join For Free

GTFS Real-Time Streaming With Apache NiFi

To facilitate ingesting GTFS Real-Time data, I have added a processor that converts GTFS (General Transit Feed Specification) formatted ProtoBuf data into JSON. This is using the standard Google APIs to accomplish this. You can see the Protocol Buffers schema here.

We will be able to get data on trip updates including delays and service alerts, including changed routes and vehicle positions that can have location and congestion information. This is the same information that these public transit systems feed to Google Maps.

An Example NiFi Flow for Accessing GTFS Data

First, we add my new NiFi Processor, which you can get as a source and build the NAR. Or download one of the release builds of my new NiFi NAR archive. This is alpha-level code done very quickly. If you find bugs, please report and suggest updates.

Once it is added to your canvas, you can change the name and scheduling.

The only setting currently is the URL of the GTFS resource (which may require a key from some transportation APIs).

Once it runs, it will quickly return a flow file containing a JSON-formatted version of the GTFS result, as well as some attributes with GTFS information.

The JSON code has a lot of arrays and subsections, not very flat. We could dump this raw to Hive and query it as a JSON document. Or, we can parse it with FlattenJSON, EvaluateJSONPath, SplitJson, or various other options.

As mentioned before, the main sections are tripUpdate, vehicle, and alerts. I will parse this and use this for real-time Slack, Kafka, HBase, and Kudu messaging. This data can become critical to companies that have trucks or people trying to navigate systems.

My first use case is to see if I can find out this data real-time during a time of emergency or events to help communities. Non-profit agents will be able to have real-time status reports of what transportation is available. You have to ingest, cleanse, and transform data to become knowledge and that can empower the community.

Join me in Puerto Rico at the NetHope Global Summit.

Source Code

https://github.com/tspannhw/gtfs/

Nar Release to Install in Apache NiFi 1.9.2

https://github.com/tspannhw/gtfs/releases

Resources

  • https://cdn.mbta.com/realtime/TripUpdates.pb
  • https://cdn.mbta.com/realtime/VehiclePositions.pb
  • https://cdn.mbta.com/realtime/Alerts.pb
  • https://www.mbta.com/developers/gtfs-realtime
  • https://github.com/CUTR-at-USF/gtfs-realtime-validator
Data processing Apache NiFi

Opinions expressed by DZone contributors are their own.

Related

  • Scaling Cloud Data Automation: A Practical Guide to Open Table Formats
  • Ten Years of Beam: From Google's Dataflow Paper to 4 Trillion Events at LinkedIn
  • Data Processing for Real Estate: Enabling Smart Analysis and Decision-Making
  • Hadoop on AmpereOne Reference Architecture

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook