Mobility

Trips

The calculation of emissions from trips is currently supported for the following modes of transport:

  • train

  • bus

  • tram

  • plane

  • ferry

  • bicycle

  • pedelec

  • car

  • motorbike

The user must specify either the distance of a trip or the location of departure and destination. The distance (in km) may be used when the user has the direct information of the distance travelled, e.g., from the speedometer of a car. In other cases, the distance can be calculated from the given locations, see Distance calculations.

Aside of the mode of transport, the user should provide the specifica of the trip, depending on the mode of transport (see Transportation modes and Emission factors).

See also:

class co2calculator.api.trip.Trip(distance: float = None, start: str | dict = None, destination: str | dict = None)[source]
by_bicycle()[source]

Initialize a bicycle trip object

Returns:

_TripByBicycle object

by_bus(fuel_type: str = None, size: str = None, vehicle_range: str = None)[source]

Initialize a bus trip object

Parameters:
  • fuel_type (str) – The fuel type of the bus (see BusFuel in constants.py)

  • size (str) – The size of the bus

  • vehicle_range (str) – The distance of the bus journey (see BusTrainRange in constants.py)

Returns:

_TripByBus object

by_car(fuel_type: str = None, size: str = None, passengers: int = 1)[source]

Initialize a car trip object

Parameters:
  • fuel_type (str) – The fuel type of the car (see CarFuel in constants.py)

  • size (str) – The size of the car (see Size in constants.py)

  • passengers (int) – number of passengers (default value: 1)

Returns:

_TripByCar object

by_ferry(ferry_class: str = None)[source]

Initialize a ferry trip object

Parameters:

ferry_class (str) – The type of seating class (see FerryClass in constants.py)

Returns:

_TripByFerry object

by_motorbike(size: str = None)[source]

Initialize a motorbike trip object

Parameters:

size (str) – The size of the motorbike

Returns:

_TripByMotorbike object

by_pedelec()[source]

Initialize a pedelec trip object

Returns:

_TripByPedelec object

by_plane(seating: str = None)[source]

Initialize a plane trip object

Parameters:

seating (str) – The type of seating class (see FlightClass in constants.py)

Returns:

_TripByPlane object

by_train(country_code: str = 'global')[source]

Initialize a train trip object

Parameters:

country_code (str) – 2- or 3-letter ISO country code

Returns:

_TripByTrain object

by_tram()[source]

Initialize a tram trip object

Returns:

_TripByTram object

calculate_distance()[source]

Calculates travelled get_distance

In addition, the user can specify a custom emission_factor for the trip using the .by_custom() method. If no distance is provided, but a start and destination, then a transport_mode is required to calculate the distance between the two locations in the appropriate way.