Free Trial

Non-Community Programs

Explore all the ways you can get involved with Alteryx, both on and off the Community!

Get Weather Data from the National Weather Service

christina-billman
Created

How To: Get Weather Data via API

 

Sentence (or two) describing the goal/task at hand (Default Font Size, Black).

 

Prerequisites

 

  • Product - Alteryx Designer

 

Procedure

This workflow pulls weather data/forecasts from the National Weather Service and transforms it into usable data. This should be considered a starting file for weather data, which can be transformed into a format that is most helpful to you, such as an analytic app or a macro.

christinabillman_0-1664478502966.png

 

 

 

  1. Edit the text input tool
    1. Fill in the longitude and latitude of the location you want weather data for
    2. Optional: Change the "user agent" to an email address if you want to receive any support emails for troubleshooting purposes in case their service goes down or changes in the future. See website at end of this post for more information.
  2. Use the "record select tool" to specify what type of forecast you want. 
    1. Select 62 for a 7 day forecast
    2. Select 63 for an hourly forecast
    3. Select 64 for forecast grid data (not parsed in the workflow)
    4. Select 65 for observation stations (not parsed in the workflow)
  3. Run the workflow

 

Details for configuration and editing:

 

Spoiler

The National Weather Service's API has to be called twice in order to get the data you want. The first API call tells the website which location you want to pull weather data for. The second API call tells the website what kind of weather data you're looking for (step 2 of the workflow instructions).

 

The first download tool pulls information for the specified location. If you look at the output of the "text to columns" tool after the first API call, scroll down to record 62-65 to see each URL option that needs to be fed back into a 2nd API call to get the weather data. Screenshot of output shown below:

christinabillman_1-1664478547138.png

 

The next few tools pull out the desired record and strips the data down to just the URL. Screenshot of output shown below:

christinabillman_2-1664478547078.png

 

The 2nd Download tool calls the desired URL to pull down the actual data. The next 3 tools clean up the received data and filters out the nulls. Screenshot:

christinabillman_3-1664478547086.png

 

This is as far as I bothered to clean up the data for options 64 and 65 (forecast grid data and observation stations). However, if 62 or 63 were selected, I continued the data cleanup process in the "clean up hourly forecast or forecast" container.

 

The top filter tool in this container contains the timestamp of when the data was generated. This is helpful to ensure your data is up to date.

 

The bottom filter tool, along with everything after, cleans out all the metadata included with the data pull, and cleans up the titles to a more usable format.

  

Additional Resources

 

Attachments
Comments
salbol1
8 - Asteroid

Very nice...I did notice the call needs to be in the format of {lat],{lon} for the API, so just needed to tweak your formula, as these were switched:

 

salbol1_0-1668109316076.png

 

Contributors
Labels