National Weather Service (NOAA) REST API returns nil for parameters of forecast

3.2k Views Asked by At

I am using the NWS REST API as my weather service for an app I am making. I was initially reluctant to use NWS because of its bad documentation, but I couldn't resist as it is offered completely free.

Now that I am trying to use it, I am running into some difficulty. When making a request for multiple days, the minimum temperature appears nil for several days.

(EDIT: As I have been testing the API more I have found that it is not always the minimum temperatures that are nil. It can be a max temp or a precipitation, it seems completely random. If you would like to make test calls using their web interface, you can do so here: http://graphical.weather.gov/xml/sample_products/browser_interface/ndfdBrowserByDay.htm

and here: http://graphical.weather.gov/xml/sample_products/browser_interface/ndfdXML.htm)

Here is an example of a request the minimum temperatures are empty: http://graphical.weather.gov/xml/sample_products/browser_interface/ndfdBrowserClientByDay.php?listLatLon=40.863235,-73.714780&format=24%20hourly&numDays=7

Surprisingly, on their website, the minimum temperatures are available: http://forecast.weather.gov/MapClick.php?textField1=40.83&textField2=-73.70

You'll see under the Minimum temperatures that it is filled with about 5 (sometimes less, it is inconsistent) blank fields that say <value xsi:nil="true"/>

If anybody can help me it would be greatly appreciated, using the NWS API can be a little overwhelming at times.

Thanks,

1

There are 1 best solutions below

0
On

The nil values, from what I can understand of the documentation, here and here, simply indicate that the data is unavailable.

Without making assumptions about NOAA's data architecture, it's conceivable that the information available via the API may differ from what their website displays.

Missing values are represented by an empty element and xsi:nil=”true” (R2.2.1).

Nil values being returned seems to involve the time period. Notice the difference between the time-layout keys (see section 5.3.2) in 1 in these requests:

The data times are different.

<layout-key> element

The key is derived using the following convention:

  1. “k” stands for key.
  2. “p24h” implies a data period length of 24 hours.
  3. “n7” means that the number of data times is 7.
  4. “1” is a sequential number used to keep the layout keys unique.

Here, startDate is the factor. Leaving it off includes more time and might account for some requested data not yet being available.

Per documentation:

The beginning day for which you want NDFD data. If the string is empty, the start date is assumed to be the earliest available day in the database. This input is only needed if one wants to shorten the time window data is to be retrieved for (less than entire 7 days worth), e.g. if user wants data for days 2-5.

I'm not experiencing the randomness you mention. The folks on NOAA's Yahoo! Groups forum might be able to tell you more.