Skip to content

get_transport_emissions

get_transport_emissions(distance_km)

Description

Get the transport CO2 emissions given the distance_km by transport mode from impactco2.fr

Usage

Call or Deploy get_transport_emissions ?
Call get_transport_emissions directly

The easiest way to use bigfunctions

  • get_transport_emissions function is deployed in 39 public datasets for all of the 39 BigQuery regions.
  • It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
  • (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)

Public BigFunctions Datasets

Region Dataset
eu bigfunctions.eu
us bigfunctions.us
europe-west1 bigfunctions.europe_west1
asia-east1 bigfunctions.asia_east1
... ...
Deploy get_transport_emissions in your project

Why deploy?

  • You may prefer to deploy get_transport_emissions in your own project to build and manage your own catalog of functions.
  • This is particularly useful if you want to create private functions (for example calling your internal APIs).
  • Get started by reading the framework page

Deployment

get_transport_emissions function can be deployed with:

pip install bigfunctions
bigfun get get_transport_emissions
bigfun deploy get_transport_emissions

Examples

Get transport emissions for 200 km

select bigfunctions.eu.get_transport_emissions(200)
select bigfunctions.us.get_transport_emissions(200)
select bigfunctions.europe_west1.get_transport_emissions(200)
+-------------------------------------------------------------------------------------------------------------------------------------------+
| co2_emissions_by_transport_mode                                                                                                           |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| [
  {"id": 2, "name": "High-speed train","value":0.46},
  {"id": 22,"name": "Carpooling combustion (1 passenger)","value":19.2},
  ...
]
 |
+-------------------------------------------------------------------------------------------------------------------------------------------+

Use cases

A logistics company uses BigQuery to store data about its deliveries. Each record in the deliveries table includes the distance_km for each delivery. The company wants to calculate the estimated CO2 emissions for each delivery, broken down by different transportation modes (e.g., truck, train, plane) to understand its environmental impact and explore potential optimizations.

They can use the get_transport_emissions function within a query like this:

SELECT
    delivery_id,
    distance_km,
    bigfunctions.eu.get_transport_emissions(distance_km) AS co2_emissions
  FROM
    `project.dataset.deliveries`;

This query adds a new column, co2_emissions, to the results. This column contains an array of structs, where each struct represents a transportation mode and its associated CO2 emission for the given distance. The company can then further process this data:

  • Aggregate emissions by transport mode: Unnest the co2_emissions array and aggregate the total emissions for each transport mode across all deliveries. This allows them to see which modes contribute most to their carbon footprint.
SELECT
    transport.name,
    SUM(transport.value) AS total_emissions
  FROM
    `project.dataset.deliveries`,
    UNNEST(bigfunctions.eu.get_transport_emissions(distance_km)) AS transport
  GROUP BY 1
  ORDER BY
    total_emissions DESC
  • Compare emissions for different delivery routes: If they have multiple potential routes for a delivery, they can use this function to estimate the emissions for each route and choose the most environmentally friendly option.

  • Scenario planning: The company could use this function to model the impact of switching to different transport modes for a portion of their deliveries. For example, what would be the CO2 reduction if 20% of truck deliveries were switched to rail?

  • Reporting and dashboards: Integrate the emission data into reports and dashboards to monitor progress towards sustainability goals.

By using the get_transport_emissions function directly within their BigQuery workflows, the logistics company can efficiently analyze their emissions data without needing to manage external APIs or data transfers. This enables them to make data-driven decisions to optimize their operations for lower environmental impact.


Need help or Found a bug?
Get help using get_transport_emissions

The community can help! Engage the conversation on Slack

We also provide professional suppport.

Report a bug about get_transport_emissions

If the function does not work as expected, please

  • report a bug so that it can be improved.
  • or open the discussion with the community on Slack.

We also provide professional suppport.


Show your ❤ by adding a ⭐ on