My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
FareExamples  
Illustrates how to implement different fare structures with the GTFS
Featured
Updated Feb 4, 2010 by naomi.bi...@gmail.com

Introduction

The fare_attributes.txt and fare_rules.txt files in the Google Transit Feed Specification can be confusing. The following examples work through different kinds of fare structures and show how to represent them in a Google transit feed.

Fare Examples

  • Example 1: All trips have the same fare, unlimited transfers
  • Example 2: All trips have the same fare, no transfers
  • Example 3: All trips have the same fare, transfers allowed
  • Example 4: Different pricing for local and express routes
  • Example 5: Buying a transfer increases the fare
  • Example 6: Fare depends on station pairs, how you get there doesn't matter
  • Example 7: Fare depends on zones

Example 1: All trips have the same fare, unlimited transfers

Suppose Demo Transit Agency has the following fare structure:

  • riders pay $1.00 on boarding (price='1.00', currency='USD', payment_method='0')
  • a ticket is good for all vehicles and doesn't expire (transfers='')
  • passengers can ride as long as they like. (transfer_duration is omitted)

Since all trips have the same fare, Demo Transit can omit fare_rules.txt.

fare_attributes.txt

fare_id price currency_type payment_method transfers
only_fare 1.00 USD 0

Calculating an adult fare

The trip planner calculates a fare of $1 for each leg of the itinerary that includes a change of vehicle. However, unlimited transfers are permitted, so the trip planner only displays the lowest charge. Adult fare: $1


Example 2: All trips have the same fare, no transfers

Suppose Demo Transit Agency has the following fare structure:

  • riders pay $1 on boarding (price='1.00', currency='USD', payment_method='0')
  • passengers can ride as long as they like. (transfer_duration is omitted)
  • any change in vehicles requires a new fare. (transfers='0')

Since all trips have the same fare, Demo Transit can omit fare_rules.txt.

fare_attributes.txt

fare_id price currency_type payment_method transfers
only_fare 1.00 USD 0 0

Calculating an adult fare

The trip planner calculates a fare of $1 for each leg of the itinerary that includes a change of vehicle. So an itinerary that requires a change of buses would be $2.


Example 3: All trips have the same fare, transfers allowed

Suppose Demo Transit Agency has the following fare structure:

  • riders pay $1 on boarding (price='1.00', currency='USD', payment_method='0')
  • unlimited transfers are allowed within 90 minutes (transfers='',transfer_duration='5400')

Since all trips have the same fare, Demo Transit can omit fare_rules.txt.

fare_attributes.txt

fare_id price currency_type payment_method transfers transfer_duration
only_fare 1.00 USD 0 5400

Calculating an adult fare

The trip planner calculates a fare of $1 for each leg of the itinerary that includes a change of vehicle. Then it calculates the time for the itinerary. If the itinerary time is less than 90 minutes, the fare is $1.


Example 4: Different pricing for local and express routes

Suppose Demo Transit Agency has the following fare structure:

  • riders pay $1.75 on boarding local buses (route 1)
  • riders pay $5 on boarding express buses (routes 2 and 3)
  • transfers aren't allowed.

Since some trips cost more than others, Demo Transit must include fare_rules.txt, and each route must have an entry to associate it with a fare.

fare_attributes.txt

fare_id price currency_type payment_method transfers
local_fare 1.75 USD 0 0
express_fare 5.00 USD 0 0

fare_rules.txt

fare_id route_id
local_fare Route_1
express_fare Route_2
express_fare Route_3

Calculating an adult fare

The $5.00 fare is only applicable if you ride routes 2 or 3. The $1.75 fare only applies on route 1. If an itinerary uses routes 1 and 2, the fare is $6.75.


Example 5: Buying a transfer increases the fare

Suppose Demo Transit Agency has the following fare structure:

  • riders pay $1.75 on boarding local buses
  • riders can pay an extra $0.25 on boarding to purchase a transfer
  • transfers purchased are valid for 90 minutes

Since these rules apply to all trips, Demo Transit can omit fare_rules.txt.

fare_attributes.txt

fare_id price currency_type payment_method transfers transfer_duration
simple_fare 1.75 USD 0 0
plustransfer_fare 2.00 USD 0 5400

Calculating an adult fare

Technically, both fares apply on itinerary that has no transfers. However, the trip planner always chooses the least expensive applicable fare:

  • For an itinerary with one transfer, simple_fare is $3.50 vs. $2.00 when a transfer is purchased. So the trip planner will report $2.00 fare on all itineraries that require a change of vehicle.
  • For an itinerary with no transfers, $1.75 fare is less than plustransfer_fare of $2.00. So if an itinerary doesn't require a change of vehicle, the fare is $1.75.


Example 6: Fare depends on station pairs, how you get there doesn't matter

In this example only the entry and exit points from the system matter.

To define this fare structure for the feed, each station must have its own unique zone ID defined in stops.txt. Each station is considered a single zone.

  • The fare_attributes.txt and fare_rules.txt files define one row for each pair of stations.
  • In fare_attributes.txt, the origin_id and destination_id fields identify station pairs by zone ID.

fare_attributes.txt

fare_id price currency_type payment_method transfers
!S1_to_S2 1.75 USD 0
!S1_to_S3 3.25 USD 0
!S1_to_S4 4.55 USD 0
...
!S10_to_S1 5.65 USD 0

fare_rules.txt

fare_id origin_id destination_id
!S1_to_S2 S1 S2
!S1_to_S3 S1 S3
!S1_to_S4 S1 S4
...
!S10_to_S1 S10 S1

Calculating an adult fare

The trip planner calculates an itinerary, and then looks up the fare rules until it finds a matching origin/destination station pair.

The public feed from SF Bay Area BART provides a real-world illustration of this type of fare structure.


Example 7: Fare depends on zones

Suppose Demo Transit Agency has a concentric three-zone system, where fares depend on which zones a rider passes through during an itinerary.

To define this fare structure for the feed, fare_attributes.txt and fare_rules.txt must contain a line for each possible combination of zones. For very complex cross-zone fare structures, it may be simpler to programmatically output fare_rules.txt using origin and destination to define fares.

fare_attributes.txt

fare_id price currency_type payment_method transfers
F1 4.15 USD 0
F2 2.20 USD 0
F3 2.20 USD 0
F4 2.95 USD 0
F5 1.25 USD 0
F6 1.95 USD 0
F7 1.95 USD 0

fare_rules.txt

fare_id contains_id
F1 1
F1 2
F1 3
F2 1
F2 2
F3 1
F3 3
F4 2
F4 3
F5 1
F6 2
F7 3

Calculating an adult fare

Let's look more closely at the definitions in fare_rules.txt.

  • F1 applies to any trip that passes through zones (1,2,3).
  • F2 applies to any trip that passes through zones (1,2).
  • F3 applies to any trip that passes through zones (1,3).
  • F4 applies to any trip that passes through zones (2,3).
  • F5 applies to any trip that passes through zone 1 only.
  • F6 applies to any trip that passes through zone 2 only.
  • F7 applies to any trip that passes through zone 3 only.

The trip planner calculates an itinerary, and then looks up the fare rules to determine the fares that apply based on zone. Since F1 also includes travel in zone 1, only F4 ($2.95) applies to a trip from zone 2 to zone 3.

A fare rule only applies when the set of zones passed through in an itinerary exactly matches the set specified by the fare rule. For a trip between zones 2 and 3, the trip planner reports $2.95 as the adult fare.

The public feed from Portland TriMet provides a real-world illustration of this type of fare structure.

Comment by tristan....@gmail.com, Jun 19, 2009

Hi I'm wondering if anyone has advise for the following transit structure: We have 2 bus types, express and regular. Regular cost 2$ and express cost 2.50. If you get on an express then move to a regular, the cost is 2.50 total because you can get a transfer. If you go from a regular to an express however, you must pay the extra 50 cents, for a total trip cost of 2.50. Any suggestions on how to code this?

Comment by Ericshaw...@gmail.com, Aug 6, 2009

If your system has multiple fare structures i.e. Full fare $1.50, all day $3.00, elderly and handicapped $.50 ect... How would you set up the codes, or is it possible? I'm thinking it would be easier to just leave out the fares and to just explain the fare structure on the website. Thanks.

Comment by antrim.a...@gmail.com, Feb 24, 2010

Is it possible to specify that a fare applies only for a particular route on travel between two zones by including the route_id, origin_id, and destination_id fields?

Can one record include the route_id and contains_id fields? What happens?

Can one record include the contains_id, origin_id, and destination_id fields? What happens?

Comment by sta...@spokanetransit.com, Feb 1, 2011

Yes, we have a situation similar to tristan (first comment). We have a shuttle route that is $.75 but regular fare is $1.50. They can transfer to a regular route within 2 hours but have to pay the additional $.75 Is there a way to show this?

Comment by taya...@gmail.com, Jun 14, 2011

For train service in between point a and b they got a station in between. the formaula of fare and pax boarding train at different station to a different station. the fomulau above show only for a journey of point a to b & transit.


Sign in to add a comment
Powered by Google Project Hosting