4.5

4.5 | 2 ratings Rate this file 19 Downloads (last 30 days) File Size: 2.45 KB File ID: #35370

Google Weather

by

 

29 Feb 2012 (Updated )

Get location specific weather data using Google's Weather API

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

 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.

Acknowledgements

This file inspired Get Geometric Location And Other Information.

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
21 Mar 2012 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.

20 Mar 2012 Andrew Bliss

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

09 Mar 2012 R

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

09 Mar 2012 Yuri K

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

Updates
01 Mar 2012

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

03 Mar 2012

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

21 Mar 2012

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

Contact us