Geo::METAR
October 26, 2008Another small module of code now, this time for the Perl programming language. Geo::METAR is a Perl module written by Jeremy Zawodny that is easy to incorporate into an existing Perl application. It allows you to query the METAR aviation weather reports at the National Weather Service. One of the big plus points for METAR data is that it is updated approximately once per hour.
METAR stands for METeorological Aviation Report and is typically used by pilots and meteorologists, it’s not typically used by lay-people as the reports are difficult to read! This Perl module will allow you to access a METAR report for a given location and then parse the results into more useful components such as wind direction, visibility, temperature etc.
Once you’ve installed the module, you’d first capture the METAR data directly from the NWS website via LWP. The url you would use in LWP to capture the METAR data for ‘KFDY’ for example is…
http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=KFDY
Then pass the results of this to the METAR module for parsing into invidual variables…
$m->metar("KFDY 251450Z 21012G21KT 8SM OVC065 04/M01 A3010 RMK 57014");
You will then have access to a wealth of weather data variables. For more information about the variables and METAR in general, visit the Wikipedia site.
To find a list of sites you can retrive METAR data for, use the ICAO site code. A list is made available here.
Now, it’s true to say that Geo::Metar is pretty static… the initial version seems to have been created around 2000 and wasn’t updated until 2008… but it does still work well and like other code modules is a good starting point for your own applications and learning. You can access the module here.
Note. It is possible to access METAR data via other means. For example the National Weather Service page on METAR tells you how to use ftp to retrive METAR data or by simply entering the 4 digit ICAO location.





