View Full Version : how can you get live METAR data ?
Bravo
October 14th 04, 05:01 PM
For you computer savvy folks in the newsgroup..... if I wanted to build a
web page for my airport that provided live METAR data, where could I get the
data from ? I see that the NWS web site has free software for decoding the
METAR codes, but where and how do you get the current weather data ? I'd
like to have something similar to what airnav does.
Paul Tomblin
October 14th 04, 05:36 PM
In a previous article, "Bravo" > said:
>For you computer savvy folks in the newsgroup..... if I wanted to build a
>web page for my airport that provided live METAR data, where could I get the
>data from ? I see that the NWS web site has free software for decoding the
Do what I do for http://xcski.com/~ptomblin/taf.html - write a perl script
to go out to the NOAA site and download it, and run it once an hour or two
out of cron.
#!/usr/bin/perl -w
# Get TAF file
use Net::FTP;
use Net::FTP::dataconn;
my @stations = ("KROC", "KBUF", "KSYR", "KART", "CYOW");
my $ftp = Net::FTP->new("weather.noaa.gov", Timeout => 600, Passive => 1);
if (!$ftp)
{
die "couldn't open ftp site";
}
$ftp->login("anonymous");
my $br = '<BR>';
$ftp->cwd("/data/forecasts/taf/stations/");
my $outstr = "<HTML><HEAD><TITLE>Local Aviation Weather</TITLE></HEAD>\n";
$outstr .= "<BODY><H1>TAFs</H1>\n";
$outstr .= "<TABLE BORDER=1>\n";
foreach $station (@stations)
{
$outstr .= "<TR>\n";
$outstr .= "<TD>$station</TD>\n";
my $dataconn = $ftp->retr($station . ".TXT");
die "TAF can't get $station" if (!defined($dataconn));
my $taf;
my $numbytes = $dataconn->read($taf, 10000);
$taf =~ s/\n/$br\n/g;
$outstr .= "<TD>$taf</TD>\n";
$outstr .= "</TR>\n";
$dataconn->abort;
}
$outstr .= "</TABLE>\n";
$outstr .= "<H1>METARs</H1>\n";
$ftp->cwd("/data/observations/metar/stations/");
$outstr .= "<TABLE BORDER=1>\n";
foreach $station (@stations)
{
$outstr .= "<TR>\n";
$outstr .= "<TD>$station</TD>\n";
my $dataconn = $ftp->retr($station . ".TXT");
die "METAR can't get $station" if (!defined($dataconn));
my $metar;
my $numbytes = $dataconn->read($metar, 10000);
$metar =~ s/\n/$br\n/g;
$dataconn->abort;
$outstr .= "<TD>$metar</TD>\n";
$outstr .= "</TR>\n";
}
$outstr .= "</TABLE>\n";
$ftp->quit;
$outstr .= "</BODY></HTML>\n";
my $fn = shift;
open(TAF, ">$fn") ;
print TAF $outstr;
close TAF;
--
Paul Tomblin > http://xcski.com/blogs/pt/
"Legacy (adj): an uncomplimentary computer-industry epithet that
means 'it works'." -- Anthony DeBoer
Matthew Chidester
October 14th 04, 06:41 PM
wow wish I knew how to do that... pearl script huh? (trying to figure out
how to do that with frontpage lol.. )
Matthew
(thanks for the tip - i've always wanted live metars on my site)
Larry Dighera
October 14th 04, 08:06 PM
On Thu, 14 Oct 2004 16:01:14 GMT, "Bravo" > wrote in
>::
>if I wanted to build a
>web page for my airport that provided live METAR data, where could I get the
>data from ?
I find that the trend over several days is often useful:
http://www.wrh.noaa.gov/total_forecast/2_day_history.php?sid=SNA
Brenor Brophy
October 15th 04, 02:29 AM
You can use PHP (yet another web programming language) to do this trick.
Checkout my home page at http://www.brenorbrophy.com/ to see the results. I
retrieve the METARs for some of my local airports, the airport name gets
color coded depending on the conditions (LIFR/IFR/MVFR & VFR), the time get
color'd red if its more than 1 hour old. I also get the TAF for a couple of
local airports. I use this to get a real quick over view of the local area
weather.
For the non-programmer, PHP is a scripting language that runs on a web
server. When somebody views the web-page the script is executed and it
outputs HTML code which is displayed on the web-page. Whoever is hosting
your web-page needs to allow PHP scripts to run. Now I'm not a PHP genius, I
hacked a piece of code called PHP Weather (version 2.1) which is available
at http://phpweather.sourceforge.net/.
Quick overview of what I did.
1) Downloaded and unziped PHP Weather. Put it in a directory on my web page
called weather.
2) Created a file called wx.php (my hack) and put it in same directory
3) Added an inline frame to my homepage as set wx.php as the source, the
HTML for this is:
<iframe src="weather/wx.php" name="wx bar" width="600" marginwidth="0"
height="170" marginheight="0" align="middle" scrolling="no"
frameborder="0"></iframe>
Here is wx.php file - it should be obivious how to modify it for a different
set of METARs and TAFs (Hint look at the arrays called $Airport & $tAirport)
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="596" border="0" cellpadding="1" cellspacing="0"
bordercolor="#CCCCCC" bgcolor="#FFFFFF">
<tr>
<td width="60%" valign="top">
<?php
//error_reporting(E_ALL);
/* We need the GET variables: */
extract($HTTP_GET_VARS);
/* Load PHP Weather */
require('../weather/phpweather.php');
if (empty($language)) $language = 'en';
$weather = new phpweather();
//$weather->properties['verbosity'] = 5;
$language = 'en';
require(PHPWEATHER_BASE_DIR . "/output/pw_text_$language.php");
$type = 'pw_text_' . $language;
require(PHPWEATHER_BASE_DIR . "/output/pw_images.php");
$icons = new pw_images($weather);
/*
** Airports array holds list of airports for METAR retrival
** tAirports array holds list of airports for TAF retrival
*/
$Airport = array ("KRHV","KWVI","KMRY","KAPC","KSCK","KSAC"); // For METAR
$tAirport = array ("KSJC","KMRY"); // For TAF
echo '<table width="100%" border="0" cellpadding="1" cellspacing="1">';
echo '<tr><td colspan="2" valign="top" bgcolor="#99CCFF"><font
face="Verdana, Arial, Helvetica, sans-serif" size="2"><strong>METAR
'.gmdate("dHi\Z")."</strong></font></td></tr>\n";
foreach ($Airport as $icao) {
$weather->set_icao($icao); // Set the airport code
$metar = $weather->get_metar(); // Get the METAR report
if($metar!='') { // If I've got a valid METAR then
$parts = explode(' ', $metar); // Break into parts so we can color
various bits
$num_parts = count($parts); // Count the parts
$time = $parts[1]; // Extract the time issued part
$vis = $parts[3]; // Extract visibility
$weather->decode_metar(); // Decode it so we can check visability &
ceiling
/*
** Check for flight conditions
** LIFR (Low IFR) is vis <1SM &|| ceiling <500' - Color ICAO purple
** IFR is 1SM < vis < 3SM &|| 500' < ceiling < 1000' - Color ICAO red
** MVFR (Marginal VFR) is 3SM < vis < 5SM &|| 1000' < ceiling < 3000' -
Color ICAO blue
** VFR is vis > 5SM & ceiling > 3000' - Color ICAO green
**
** Ceiling is altitude of lowest cloud type of BKN or OVC
*/
$vis = $weather->decoded_metar['visibility'][0]['miles']; // Get
visibility
$layer = $weather->decoded_metar['clouds']; // Get the cloud layers
$ceiling = 999999; // Init ceiling value
$group_num = 0; // Init cloud group value (there could be up to 3
cloud groups)
foreach ($layer as $key=>$group) { // For each cloud group
/*
** We only care about OVC or BKN layers
*/
if (($group['condition'] == 'OVC') || ($group['condition'] == 'BKN') ||
($group['condition'] == 'VV')) {
if ($ceiling > $group['ft']) { // Look for the lowest ceiling
$ceiling = $group['ft']; // Records it if lower
$group_num = $key; // Record the cloud group it occurs in
} // end of found a lower ceiling
} // end of condition OVC || BKN || VV
} // end of checking all cloud layers
if (($vis <= 1) || ($ceiling <= 500)) {
$flight_condition = 'LIFR';
($vis <= 1) ? $vis_flag = true : $vis_flag = false;
($ceiling <= 500) ? $ceiling_flag = true : $ceiling_flag = false;
}
elseif (($vis <= 3) || ($ceiling <= 1000)) {
$flight_condition = 'IFR';
($vis <= 3) ? $vis_flag = true : $vis_flag = false;
($ceiling <= 1000) ? $ceiling_flag = true : $ceiling_flag = false;
}
elseif (($vis <= 5) || ($ceiling <= 3000)) {
$flight_condition = 'MVFR';
($vis <= 5) ? $vis_flag = true : $vis_flag = false;
($ceiling <= 3000) ? $ceiling_flag = true : $ceiling_flag = false;
}
else {
$flight_condition = 'VFR';
$vis_flag = false;
$ceiling_flag = false;
}
echo '<tr><td valign="top"><font face="Verdana, Arial, Helvetica,
sans-serif" size="1" ';
switch ($flight_condition)
{
case 'LIFR': $color="#FF00FF"; break; // Purple color
case 'IFR' : $color="#FF0000"; break; // Red color
case 'MVFR': $color="#0000FF"; break; // Blue color
case 'VFR' : $color="#009900"; break; // Green color
default : $color="#000000"; // Should never happen but in case
leave it black color
}
echo 'color="'.$color.'"><strong>'.$icao."</strong></font></td>\n"; //
print the airport code and close the cell
/*
** Now we want to alert the user if the METAR data is old. So we will color
the time stamp red if
** its is more than 1 hour old.
*/
echo '<td valign="top"><font face="Verdana, Arial, Helvetica,
sans-serif" size="1" '; // Start the cell and set the font
if ($weather->metar_time < time()-3600) { // METAR is more then 1
hour old
echo 'color="#FF0000">';
} else { // METAR is less than 1 hour old
echo 'color="#000000">';
} // end of METAR time check
echo $time.'</font>';
/*
** print remainder of the METAR
**
** Plan to add color high-light of Vis or cloud causing !VFR flight
conditiond
*/
echo '<font face="Verdana, Arial, Helvetica, sans-serif"
size="1">'.substr($metar,12,strlen($metar))."</td></tr>\n";
} // end of valid METAR
} // end of FOREACH loop on array of airports
echo "</table></font><br>\n";
?>
</td>
<td width="40%" valign="top">
<?php
$text = new $type($weather);
foreach ($tAirport as $icao) {
$text->weather->set_icao($icao); // Set the Airport code
$taf = $text->weather->decode_taf(); // Get and decode the TAF
if($taf['taf']!='') { // If I've got a valid TAF then
$parts = explode(' ', $taf['taf']); // Break into parts so we can
color various bits
$num_parts = count($parts); // Count the parts
$time = $parts[1]; // Extract the time issued part
echo '<table width="100%" border="0" cellpadding="1"
cellspacing="1">';
echo '<tr><td valign="top" bgcolor="#99CCFF"><font face="Verdana,
Arial, Helvetica, sans-serif" size="2"><strong>TAF '.$icao."
".$time."</strong></font></td></tr>\n";
echo '<tr><td valign="top"><font face="Verdana, Arial, Helvetica,
sans-serif" size="1">';
while(list($i,$period) = each($taf['periods2'])) {
echo $period['data']."<br>\n";
} // end of while list of TAF periods
echo "</td></tr>\n";
echo "</table>";
} // end of valid TAF
} // end of FOREACH loop on array of airports
?>
</td>
</tr>
</table>
</body>
</html>
Matthew Chidester
October 15th 04, 05:10 PM
wow those are great ideas guys..
I was telling another guy this, what I'd like to do is when I become a CFI
here in salt lake - i'd like to be able to get live metar/taf's in a small
font on a basic html page so I could use a web enabled phone to pull up the
data at any time without running to a pc (I think it would be a cool idea)
I've heard of some company out there that provides live radar and metar/taf
data but they charge a price. Instead you could use link radar maps and
resize them and include the metar/taf data for free on your own personal web
page.
Anyway thanks again for the info guys - I'll have to do some trial and
error.
Matthew
Paul Sengupta
October 18th 04, 02:00 PM
"Matthew Chidester" > wrote in message
news:wDSbd.186189$wV.63846@attbi_s54...
> wow those are great ideas guys..
>
> I was telling another guy this, what I'd like to do is when I become a CFI
> here in salt lake - i'd like to be able to get live metar/taf's in a small
> font on a basic html page so I could use a web enabled phone to pull up
the
> data at any time without running to a pc (I think it would be a cool idea)
You can get TAFs/METARs on a WAP phone using one of:
http://www.wapmx.com (Aviation Weather from the index)
http://wap.cupitt.com
(all on the phone)
There are others out there too.
Paul
Matthew Chidester
October 20th 04, 06:15 PM
Oh sweet thanks Paul :)
Matthew
> You can get TAFs/METARs on a WAP phone using one of:
> http://www.wapmx.com (Aviation Weather from the index)
> http://wap.cupitt.com
> (all on the phone)
>
> There are others out there too.
>
> Paul
>
>
Blueskies
October 26th 04, 01:33 AM
A couple of goodies here:
http://www.wxplotter.com/software.php
"Bravo" > wrote in message ...
> For you computer savvy folks in the newsgroup..... if I wanted to build a
> web page for my airport that provided live METAR data, where could I get the
> data from ? I see that the NWS web site has free software for decoding the
> METAR codes, but where and how do you get the current weather data ? I'd
> like to have something similar to what airnav does.
>
>
>
Bob Fry
November 2nd 04, 07:30 PM
"Paul Sengupta" > wrote in message >...
> You can get TAFs/METARs on a WAP phone using one of:
> http://www.wapmx.com (Aviation Weather from the index)
> http://wap.cupitt.com
> (all on the phone)
>
> There are others out there too.
>
> Paul
Hi Paul,
Do you know of any services--preferably free--that will accept a cell
phone SMS message with ICAO IDs, and send an SMS message back with
METARs and TAFs?
Paul Tomblin
November 3rd 04, 12:59 AM
In a previous article, (Bob Fry) said:
>Do you know of any services--preferably free--that will accept a cell
>phone SMS message with ICAO IDs, and send an SMS message back with
>METARs and TAFs?
I wrote one. But unfortunately a SMS message is too short, so it ends up
coming back as three messages.
--
Paul Tomblin > http://xcski.com/blogs/pt/
I'm a person who can't understand why everyone in the entire nation
doesn't look up, realise that George W Bush is their president, and not
immediately throw up in their mouths. Shows what I know. - Harry Teasley
Bob Fry
November 3rd 04, 01:38 AM
(Paul Tomblin) writes:
> In a previous article, (Bob Fry) said:
> >Do you know of any services--preferably free--that will accept a cell
> >phone SMS message with ICAO IDs, and send an SMS message back with
> >METARs and TAFs?
>
> I wrote one. But unfortunately a SMS message is too short, so it ends up
> coming back as three messages.
Hmmm, is it available to the vast r.a.* audience?
BF
Paul Tomblin
November 3rd 04, 08:16 AM
In a previous article, Bob Fry > said:
(Paul Tomblin) writes:
>> In a previous article, (Bob Fry) said:
>> >Do you know of any services--preferably free--that will accept a cell
>> >phone SMS message with ICAO IDs, and send an SMS message back with
>> >METARs and TAFs?
>>
>> I wrote one. But unfortunately a SMS message is too short, so it ends up
>> coming back as three messages.
>
>Hmmm, is it available to the vast r.a.* audience?
I'm a little reluctant to share because I don't know what sort of volume
it might get. Give it a try, send an sms to . You can
specify the stations in the subject line or in the body. If the volume
gets too high, I'll turn it off.
--
Paul Tomblin > http://xcski.com/blogs/pt/
You can be jailed for lying about being good in bed.
-- Lionel, paraphrasing the Criminal Code of Canada, 159(3)(b)(i)
Scott D.
November 5th 04, 06:19 AM
On Wed, 3 Nov 2004 08:16:24 +0000 (UTC),
(Paul Tomblin) wrote:
>In a previous article, Bob Fry > said:
(Paul Tomblin) writes:
>>> In a previous article, (Bob Fry) said:
>>> >Do you know of any services--preferably free--that will accept a cell
>>> >phone SMS message with ICAO IDs, and send an SMS message back with
>>> >METARs and TAFs?
>>>
>>> I wrote one. But unfortunately a SMS message is too short, so it ends up
>>> coming back as three messages.
>>
>>Hmmm, is it available to the vast r.a.* audience?
>
>I'm a little reluctant to share because I don't know what sort of volume
>it might get. Give it a try, send an sms to . You can
>specify the stations in the subject line or in the body. If the volume
>gets too high, I'll turn it off.
There use to be an AIM nickname called Pilotsmart Metar that if you
sent a text message to it with only the airport identifier in the
body, it would return the current metar.
I actually liked using it on my phone that had AIM on it, but I have
not seen it up in quite some time.
Scott D.
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.