Get latest weather reports from weather stations worldwide
The information comes from the National Oceanic and Atmospheric Association's raw data source.
require 'rubygems' if RUBY_VERSION < '1.9'
require 'metar'
This prints the latest weather report for Portland International Airport:
station = Metar::Station.find_by_cccc( 'KPDX' )
puts station.report.to_s
List countries:
puts Metar::Station.countries
Find a country's weather stations:
spanish = Metar::Station.find_all_by_country( 'Spain' )
station = Metar::Station.find_by_cccc( 'KPDX' )
parser = station.parser
puts parser.temperature.value
metar_string = "KHWD 280554Z AUTO 29007KT 10SM OVC008 14/12 A3002 RMK AO2 SLP176 T01390117 10211\n"
raw = Metar::Raw::Data.new( metar_string )
parser = Metar::Parser.new( raw )
This version introduces a major change to the Metar::Raw class.
Previously, this class downloaded METAR data from the NOAA FTP site. The old functionality has been moved to Metar::Raw::Noaa. The new class, Metar::Raw::Data accepts a METAR string as a parameter - allowing the user to parse METAR strings without necessarily contacting the NOAA.
Other Ruby libraries offering METAR parsing:
There are many reports (WMO) that these libraries do not parse.
There are two gems which read the National Oceanic and Atmospheric Association's XML weather data feeds: