Better with weather

Enhance your maps with The Weather Company APIs

No items found.

Jul 13, 2021

Better with weather

Enhance your maps with The Weather Company APIs

Guest

No items found.

Guest

Jul 13, 2021

IBM is the founding partner of Call for Code, a global "tech for good" initiative, which includes the multi-month Global Challenge. Call for Code is the largest and most ambitious effort bringing together developers to take on pressing societal issues using open source technology. Since 2018 this movement has grown to over 400,000 developers across 179 nations who have answered the call. Developers access rich weather data APIs from The Weather Company (an IBM business) for free during the challenge. The APIs integrate seamlessly with Mapbox, allowing developers to create new experiences that incorporate weather.


The winning solutions are successfully incubated, field-tested, and deployed in communities where they can make the greatest impact. This year's competition is open for submissions through July 31st, and invites the world's software developers and innovators to help mitigate the impact of climate change with open source-powered technology.

Outdoor apps like AllTrails use weather data to help their users assemble the equipment they might need at elevation. Navigation apps like the General Motors™ integration of Mapbox Dash can help drivers plan ahead with better ETAs and upcoming conditions like snow or heavy rain. Insurance companies like Progressive™ incorporate historical and live weather data to analyze the risk for a mortgage underwriter’s portfolio.


Weather is inherently geographic. Location shapes weather, while weather can define the feeling of being at a particular place at a moment in time or even change your experience there. With information about current, past, and future weather, app developers can create a more valuable experience and help end users make more informed decisions about the impact weather may have on their plans.

"As consumers check their local weather on weather.com and The Weather Channel app, flexible and fast mapping is critical to help them better understand not only what the forecast is, but what it means for the locations that matter to them." – Krista Rouse, head of consumer product, IBM’s The Weather Company

The Weather Company (TWCo) makes a prolific set of data products available via API. From the familiar data found in any weather app, like temperature and precipitation, to threshold/product-driven analytics, participating developers will have access to TWCo weather data APIs to help enhance applications they develop as part of Call for Code.

Search for a place to get current weather conditions at that location

As an example of how weather data APIs can be integrated, this demo uses two different TWCo products: a radar overlay for the map, and current conditions for a search result. Current radar data is visible when the map loads. Its position in the map layer stack keeps place labels and roadways visible above the radar layer. After searching for a place and while the map zooms in, the code makes a secondary request to TWCo for the current conditions. Once the map centers on the search result, the corner of the map displays the current weather and temperature.

Radar API

Requesting map tiles from TWCo is a two-step process. New radar data is available every five minutes. The request for the map tiles needs to specify the point-in-time at which TWCo published the tiles. The radar metadata endpoint includes a list of available “time slices” . Call the metadata endpoint first and extract the last time slice in the time array. Then use that time as an input to the map tile request.

Once the map tile URL is available, and the map load event fires, the code adds the radar layer to the map. Use the `before_layer` parameter to specify where the radar should display in the map drawing order, in this case, the “aeroway-line” layer.

Current Conditions API

Current conditions are not displayed when the map first loads, since it displays a large geographic area. Once a user searches for a place, the code uses that result to pinpoint the user’s area of interest. Once the Mapbox Search API response comes in, the app uses the coordinates of the search result to request the current weather conditions at that place.

The demo displays the current temperature and weather conditions in a div on top of the map. This endpoint has dozens of data elements, so the app could also include wind speed, air quality index (AQI), humidity, or pressure.

How to Join Call for Code

Sign up for an account at Call for Code to get a TWCo API key (note that you’ll need to create an IBM account during this process. Please see the IBM Privacy Policy here). Sign up for a Mapbox account if you don’t have one.


Fork or download the demo sample code, and add your API keys in the variables at the top of the script.

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Block quote

Ordered list

  1. Item 1
  2. Item 2
  3. Item 3

Unordered list

  • Item A
  • Item B
  • Item C

Text link

Bold text

Emphasis

Superscript

Subscript

No items found.
No items found.