Skip to main content

🧪 GTFSRealtimeLoader

From-v5.0Status: Experimental

GTFSRealtimeLoader decodes a binary GTFS Realtime snapshot. The default output contains one row per vehicle-position entity with coordinates. Use the feed shape to access trip updates, alerts, shapes, stops, trip modifications, deletion markers, and vehicle reports without positions.

🧪 GTFSRealtimeLoader
Automatic selection.gtfs-realtime
Explicit selectionStandard .pb and extensionless feed URLs
Data formatApache Arrow Table, ObjectRowTable, or GTFSRealtimeFeed
Supported APIsload, parse, parseSync (bundled loader)

Usage​

import {load} from '@loaders.gl/core';
import {GTFSRealtimeLoader} from '@loaders.gl/scientific/gtfs-realtime';

const feed = await load('VehiclePositions.pb', GTFSRealtimeLoader, {
gtfsRealtime: {shape: 'gtfs-realtime-feed'}
});

Pass GTFSRealtimeLoader directly to select it for generic protobuf files or URLs. For synchronous parsing, import GTFSRealtimeLoader or GTFSRealtimeLoaderWithParser from @loaders.gl/scientific/gtfs-realtime/bundled.

Options​

OptionDefaultDescription
gtfsRealtime.shape'arrow'Return an Arrow vehicle table, an 'object-row-table' with the same columns, or a 'gtfs-realtime-feed' with the decoded header and entities.

Vehicle table schema​

Deleted entities and vehicle reports without a position are omitted. Missing optional values appear as null. The default stop status is IN_TRANSIT_TO.

ColumnTypeMeaning
timestampfloat64Vehicle observation time in Unix seconds.
idstringFeed entity identifier.
vehicleId, vehicleLabelstringVehicle identifier and passenger-facing label.
tripId, routeIdstringTrip and route identifiers from the vehicle's trip descriptor.
directionIduint32Trip direction.
startDate, startTimestringTrip start date and service-day time.
longitude, latitudefloat64Decimal degrees, east and north positive.
bearingfloat64Degrees clockwise from true north.
speedfloat64Metres per second.
currentStatusstringVehicle stop status enum name.
stopIdstringReferenced GTFS Schedule stop.
occupancyStatusstringPassenger occupancy enum name.
occupancyPercentageuint32Reported passenger occupancy percentage.

String-valued schema metadata contains gtfsRealtimeVersion and incrementality, plus timestamp (feed creation time in Unix seconds) and feedVersion when supplied. Read these with table.schema.metadata.get(key) in Arrow or table.schema.metadata[key] in an object-row table.

Decoded feed​

GTFSRealtimeFeed contains shape: 'gtfs-realtime-feed', header, and an entity array in wire order. It uses camelCase property names and protobuf enum names. Repeated fields are arrays, and omitted optional fields are absent unless the protocol declares an explicit default. Each translated text or URL field contains a translation array with every supplied text and language tag. Timestamps are JavaScript numbers in Unix seconds and must fit the safe integer range.

Feed propertyContents
tripUpdate.tripPropertiesDuplicate trip tripId, startDate, and startTime, plus shapeId, tripHeadsign, and tripShortName overrides.
tripUpdate.stopTimeUpdate[].stopTimePropertiesassignedStopId for platform assignments, stopHeadsign, and the pickupType and dropOffType enum names REGULAR, NONE, PHONE_AGENCY, and COORDINATE_WITH_DRIVER.
alertIncludes ttsHeaderText, ttsDescriptionText, severityLevel (default UNKNOWN_SEVERITY), imageAlternativeText, causeDetail, and effectDetail. image.localizedImage entries contain url, mediaType, and an optional language.
shapeshapeId and encodedPolyline as supplied by the feed.
stopstopId, stopLat, stopLon, zoneId, parentStation, stopTimezone, levelId, and wheelchairBoarding (default UNKNOWN). stopCode, stopName, ttsStopName, stopDesc, stopUrl, and platformCode are translated fields.
tripModificationsselectedTrips groups contain tripIds and shapeId. The entity also contains startTimes, serviceDates, and modifications. Each modification has startStopSelector and endStopSelector (with stopSequence or stopId), propagatedModificationDelay (default 0 seconds), replacementStops (with travelTimeToStop in seconds and stopId), serviceAlertId, and lastModifiedTime.

For a DUPLICATED trip, tripUpdate.trip.tripId identifies the original scheduled trip. Join its update to a vehicle report by matching tripUpdate.tripProperties.tripId to vehicle.trip.tripId. A platform assignment is available at tripUpdate.stopTimeUpdate[].stopTimeProperties.assignedStopId.