Friday, November 19, 2010

Weather forecast widget: Weather providers

The one of main parts of weather forecast widget is communication with weather provider.

I have found next providers (please let me know if you know another ones) that work only with the US cities (except Google weather):
Google weather API
Google provides API for getting weather data for US cities by name.
Next is the link to get weather data
The received weather data are stored in XML and contains next:
  • Information about received data (city name, state, forecast date)
  • Current weather conditions:
    • Conditions (Sunny, Rain, Cloudy, Showers etc)
    • Temperature (both Celsius and Fahrenheit)
    • Humidity (in percents)
    • Wind conditions
    • Weather icon (link to icon stored on Google)
  • Weather forecast for next few days:
    • Day of week of forecast (Mon, Tue, Wed etc)
    • Conditions (Rain, Cloudy, Showers etc) 
    • Low temperature (in Fahrenheit)
    • High temperature (in Fahrenheit)
    • Weather icon (link to icon stored on Google)
Here is a sample XML received for NY
<xml_api_reply version="1">
     <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0"> 
<city data="New York, NY"/>
<postal_code data="new york,ny"/>
<latitude_e6 data=""/>
<longitude_e6 data=""/>
<forecast_date data="2010-05-20"/>
    <current_date_time data="2010-05-20 07:44:43 +0000"/>
    <unit_system data="US"/>
            <condition data="Cloudy"/>
            <temp_f data="59"/>
            <temp_c data="15"/>
            <humidity data="Humidity: 80%"/>
            <icon data="/ig/images/weather/cloudy.gif"/>
            <wind_condition data="Wind: N at 0 mph"/>
            <day_of_week data="Thu"/>
            <low data="61"/>
            <high data="79"/>
            <icon data="/ig/images/weather/sunny.gif"/>
            <condition data="Sunny"/>
            <day_of_week data="Fri"/>
            <low data="60"/>
            <high data="83"/>
            <icon data="/ig/images/weather/partly_cloudy.gif"/>
            <condition data="Partly Cloudy"/>

Next are some Google weather icons:

WeatherForecast web service from
This web service supports the following two operations:
  • GetWeatherByPlaceName - returns weather forecast for a place name (US cities only)
  • GetWeatherByZipCode - returns weather forecast for a Zip Code (US only)
The first one looks like the Google Weather API defined above. Let investigate it.
To get weather forecast for city it is possible to use HTTP POST request, like this (for New York).
The received weather data are stored in XML:
  • Information about received data (city name, latitude & longitude, state)
  • Weather forecast for next week:
    • Date for forecast
    • Low temperature in Fahrenheit and Celsius
    • High temperature in Fahrenheit and Celsius
    • Weather icon (link to icon from, see below NDFD)
As you can see, there are poor weather data, but they contain almost all that we need, excluding weather conditions.
Next is a sample XML for NY
     <PlaceName>NEW YORK</PlaceName>
               <Day>Tuesday, May 25, 2010</Day>
               <Day>Wednesday, May 26, 2010</Day>
               &lt;Day>Thursday, May 27, 2010</Day>
               <Day>Friday, May 28, 2010</Day>
               <Day>Saturday, May 29, 2010</Day>

Note this Web service is unavailable time to time.

National Digital Forecast Database
National Digital Forecast Database (NDFD) SOAP web service provides data from the National Weather Service’s (NWS) digital forecast database. It uses XML to store weather data. The NDFD XML language is called Digital Weather Markup Language (DWML) and its schema can be found here.

NDFD web service contains a lot of functions to get weather data. This page uses one of them.

Next is the XML data for Baltimore, MD (please correct date in link) received from NDFDgenByDay
<dwml version="1.0" xsi:noNamespaceSchemaLocation="">
        <product srsName="WGS 1984" concise-name="dwmlByDay" operational-mode="official">
                NOAA's National Weather Service Forecast by 24 Hour Period
            <creation-date refresh-frequency="PT1H">2010-05-21T08:45:54Z</creation-date>
                Meteorological Development Laboratory
                <sub-center>Product Generation Branch</sub-center>
            <point latitude="39.29" longitude="-76.61"/>
        <moreWeatherInformation applicable-location="point1">
        <time-layout time-coordinate="local" summarization="24hourly">
        <time-layout time-coordinate="local" summarization="12hourly">
        <time-layout time-coordinate="local" summarization="24hourly">
        <parameters applicable-location="point1">
            <temperature type="maximum" units="Fahrenheit" time-layout="k-p24h-n2-1">
                <name>Daily Maximum Temperature</name>
            <temperature type="minimum" units="Fahrenheit" time-layout="k-p24h-n2-1">
                <name>Daily Minimum Temperature</name>
            <probability-of-precipitation type="12 hour" units="percent" time-layout="k-p12h-n4-2">
                <name>12 Hourly Probability of Precipitation</name>
            <weather time-layout="k-p24h-n2-1">
                <name>Weather Type, Coverage, and Intensity</name>
                <weather-conditions weather-summary="Partly Sunny"/>
                <weather-conditions weather-summary="Chance Thunderstorms">
                    <value coverage="chance" intensity="none" weather-type="thunderstorms" qualifier="none"/>
                    <value coverage="chance" intensity="light" additive="and" weather-type="rain showers" qualifier="none"/>
            <conditions-icon type="forecast-NWS" time-layout="k-p24h-n2-1">
                <name>Conditions Icons</name>
            <hazards time-layout="k-p2d-n1-3">
                <name>Watches, Warnings, and Advisories</name>
                <hazard-conditions xsi:nil="true"/>

Next are some weather icons:

NDFD provides all necessary weather data for each point of the USA and I suppose all defined above providers use data from this one.
The disadvantage of using NDFD web service from Android, is the used DWML format for storing weather data. It is some difficult to parse it.

As for me, it's enough to use the Google provider - it provides as current condition as forecast for next few days stored in simple XML.

Note this post was created in May 2010; I planned to post it before, but did not have enough time to finish it. This is why there is used weather data for the May month.

No comments:

Post a Comment