Skip to content

transitlos.vehicle_km

Daily vehicle-kilometres of a GTFS feed inside any number of areas.

vehicle_km = sum over the trips that run on the day of (runs of the trip) x (length of the trip inside the area): * trips that run: services active on day (calendar.txt + calendar_dates.txt); * runs: 1 for a normal trip; a trip listed in frequencies.txt runs (end_time - start_time) // headway_secs times per window (a trip every 5 minutes is 12 trips an hour); * length: the shapes.txt line of the trip clipped to the area; a trip without a shape uses straight lines between its stops. Shared by the city studies (metro / core) and the US study (every county and place).

scan_csv(path)

Lazy GTFS table with BOM-stripped column names; quote handling disabled for files with literal quotes inside fields.

Parameters:

Name Type Description Default
path Path

GTFS text file.

required

Returns:

Type Description
Optional[LazyFrame]

LazyFrame of text columns, or None.

active_trips(gtfs_dir, day)

trip_id, runs, shape_id of every trip running on day (frequency windows expanded into runs).

Parameters:

Name Type Description Default
gtfs_dir Path

Unzipped GTFS folder.

required
day date

Service date.

required

metric_crs_for(lon, lat)

The UTM zone CRS of a point.

Parameters:

Name Type Description Default
lon float

Longitude.

required
lat float

Latitude.

required

Returns:

Type Description
CRS

pyproj CRS.

vehicle_km_by_area(gtfs_dir, day, areas_metric, to_metric)

(vehicle_km, trip_runs) of the feed on day inside each area (same order as areas_metric, polygons in the metric CRS).

Parameters:

Name Type Description Default
gtfs_dir Path

Unzipped GTFS folder.

required
day date

Service date.

required
areas_metric GeoSeries

Areas in a metric CRS.

required
to_metric Transformer

Transformer from EPSG:4326 to that CRS.

required