File Exchange

image thumbnail

Google Weather

version 1.6 (2.45 KB) by

Get location specific weather data using Google's Weather API

7 Downloads

Updated

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Google Weather
Get location specific weather data using Google's Weather API

Usage:
1. gweather()
2. gweather('place') Ex. gweather('Goa')
3. gweather(lat,long) Ex. gweather(15.563,73.818)
(lat,long in decimal degrees)

Besides printing the current conditions and the forecast, the function
returns the forecast information in a structure. (Output)

Sample Output:

Location:Natick,MA
Current Conditions:
3°C, 86% Humidity, Light rain

Forecast:
Thu: -7°C to 3°C, Icy
Fri: 0°C to 2°C, Mostly Sunny
Sat: 0°C to 10°C, Rain
Sun: -6°C to 6°C, Cloudy

Note
Apparently, the Google Weather XML Feed is not officially supported.
Use of lat,long often provides unreliable results.

Comments and Ratings (6)

Ikko

Ikko (view profile)

Hi!
Google weather API has closed, and there is no URL any more, which is why we have an error.
(http://thenextweb.com/google/2012/08/28/did-google-just-quietly-kill-private-weather-api/)

kyana shayan

it doesn't work for me.
i got this message
Error using urlreadwrite (line 90)
The server did not find a resource to match this request.

Error in urlread (line 36)
[s,status] = urlreadwrite(mfilename,catchErrors,url,varargin{:});

Error in gweather (line 64)
data = urlread(url);
can anyone help me?

Sagar Aiya

Thanks Yuri Kotliarov and R for your suggestion about clc.

Thanks a lot Andrew Bliss!
That flaw went unnoticed for quite some time. One of the reasons being that low temperatures (forecasts) were retrieved in deg F and later converted into deg Celsius before printing. That way, I could get temperatures as low as 0 deg F (-17.78 deg C) but not any lower.

I've made necessary changes and will upload the file soon.

Andrew Bliss

Andrew Bliss (view profile)

A nice function. Parsing is generally good, but failed for negative temperatures when I ran it. To fix:

For CURRENT_CONDITIONS and FORECASTS change [\w\s\d_/<>=%":.]* to .*

For TEMP, LOWS, and HIGHS change [\d] to [-\d]

Also, not everyone will want an output structure. Get around that with:
function outputstruct = gweather...
...%(your whole function)
if nargout
outputstruct = Output;
end

R

R (view profile)

I agree clc is bad practice for a function to be distributed, otherwise great job

Yuri K

Yuri K (view profile)

Cool! But clc is not a good practice in function.

Updates

1.6

- clc has been removed.
- Fixed the issue of negative temperatures as suggested by Andrew Bliss.

1.4

Uploaded the updated gweather.m file which I forgot to upload during the previous update.

1.3

provision to supply geographical coordinates as arguments instead of a location name.

MATLAB Release
MATLAB 7.10 (R2010a)
Tags Add Tags

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video