Skip to main content
Data visualization 4 min read

How we built the commuter carbon calculator app


Earth Day 2023 is approaching. We are taking this opportunity to share an app we built to calculate the carbon emissions associated with our daily activities. Transportation accounts for around one-fifth of global carbon dioxide emissions, and for individuals, transportation is one of the largest contributors. In this blog post, I will introduce some unique capabilities available in this app and share some insights into how it was built. 

Preparing the Data 

The first step in creating a commuter Carbon emissions calculator is knowing the greenhouse gas emitted by different modes of transportation. We chose to use Our World in Data organization’s data that is sourced from the UK Government’s methodology paper for greenhouse gas reporting. The data is available for download as csv with the carbon footprint for different modes of travel. The carbon footprint is measured in grams of carbon dioxide-equivalents per passenger kilometer.  

co2 emission scores

HERE Maps and API usage 

The map is created using the HERE Maps API for JavaScript. The application uses React framework. After showing the map for our chosen extent, and adding basic functionality like zoom, pan, and events handling, we will use move on to routing. If you are new to HERE Maps API for JavaScript, follow this blog post to add a fully functional map. 

In the app, you can choose a starting point and a destination anywhere in the US. We geocode the entered Origin and Destination locations and provide autocomplete suggestions.  

        const searchService = get().platform.getSearchService() 

export function search(value, searchService, center = [38, -95]) {
  return new Promise((resolve) => {
        q: value,
        in: `countryCode:${countriesToSearch}`, //"USA"
        at: center.join(","), // "38,-95"
        lang: "en",
        limit: 20,
      (result) => {
        const suggestions = result.items
          .filter(({ resultType, localityType }) => {
            return resultType === "houseNumber" || localityType === "city" || resultType === "place"
          .map(({ address, id, position, resultType, localityType }, i) => {
            if (resultType === "locality") {
              const items = address.label.split(",")
              const cityLabel =
                items[0].trim() + ", " + items[items.length - 1].trim()
              return {
                key: i,
                label: address.label,
                position: [, position.lng],
            } else {
              return {
                key: i,
                label: address?.label,
                cityLabel: "",
                position: [, position.lng],
          .slice(0, 5)


We then use the HERE Routing API to calculate the distance and time needed to reach the destination by a chosen means of transport.

        export function computePrivateTransportRoute(
  origin = [40.748483722760795, -73.98565233747497],
  destination = [42.37717865417409, -71.11603020809282],
  transportMode = "car",
  routingMode = "fast"
) {
  const routingParameters = {
    transportMode, // "car" "truck" "pedestrian" "bicycle" "scooter" "taxi"
    origin: origin.join(","),
    destination: destination.join(","),
    "avoid[features]": "ferry,carShuttleTrain", 
       // Avoid the problem of using ferries when computing bicycle routes
    return: ["polyline", "summary", "travelSummary"],

  const router = platform.getRoutingService(null, 8)

  return new Promise((resolve, reject) => {
    router.calculateRoute(routingParameters, resolve, reject)


Then the route is drawn on the map, and summary of the carbon footprint is displayed. There is an option to show the route summary and carbon footprint for one-way travel, or daily/annual commute. In the tab next to Route Summary, we also show an comparison of carbon footprint along this route for different modes of transport.

The map is styled with a custom YAML file as described in our documentation

By changing the mode of transport, the route length can vary, as well as the travel and emissions. For example, if you choose bicycle instead of car, the route will avoid highways. The travel time will increase but the emissions levels for bicycles will be much lower. This capability is the unique feature of this map. 



With this commuter's carbon footprint calculator, let's take an active role in reducing our impact on the planet. We are now equipped to take better informed decisions about our transportation choices. I hope this also persuades you to choose more environmentally friendly options such as carpooling, using public transportation, biking, or walking, which also happen to be healthy. Let's all do our part and contribute to a more sustainable future for our planet.

Mohini Todkari

Mohini Todkari

Sr. Developer Evangelist

Have your say

Sign up for our newsletter

Why sign up:

  • Latest offers and discounts
  • Tailored content delivered weekly
  • Exclusive events
  • One click to unsubscribe