Weather station scripts - METAR display

They're free, but use at your own risk

The scripts referenced here are used in the operation of this weather station, and may be freely copied and used to support your station. Please note that you use these scripts at your own risk. No warranty is expressed or implied. I accept no liability for any damages that may ensue from their use.
You will need to configure them for your own particular weather station website.
RSS feed for Scripts Updates A RSS Feed is available to help keep you informed on updates to the scripts.

If you find one or more of the scripts useful to you, please consider making a donation to help offset the routine expenses of operation of this website.
Thanks for your kind support!

A Version History is available -- check back from time to time to see if there are updates to scripts you have downloaded earlier. Announcements of version updates and new scripts are made on and Weather-Watch forums and saratogaWXPHP Twitter account as they become available.

This page was updated Friday, 30-Nov-2018 10:04 AM

METAR conditions display

This package of scripts is designed for standalone (outside the Saratoga AJAX/PHP template set) use. The equivalent function is already built in to the wxmetar.php page in the template set.

It uses two of the built-in functions from the template set:
so to have easy maintenance for future releases of those two scripts, it is strongly recommended you not modify them. All needed customization can be performed in the metar-display.php script.

Sample output

Settings inside metar-display.php sample page


// Customize this list with your nearby METARs by
// using to create the list below

$MetarList = array( // set this list to your local METARs 
// Metar(ICAO) | Name of station | dist-mi | dist-km | direction |
  'KNUQ|Moffett Nas/Mtn, California, USA|9|14|N|', // lat=37.4000,long=-122.0500, elev=12, dated=28-FEB-12
  'KSJC|San Jose, California, USA|9|14|NE|', // lat=37.3667,long=-121.9167, elev=24, dated=28-FEB-12
  'KRHV|San Jose/Reid, California, USA|12|19|ENE|', // lat=37.3167,long=-121.8167, elev=41, dated=28-FEB-12
  'KPAO|Palo Alto, California, USA|14|23|NNW|', // lat=37.4667,long=-122.1167, elev=2, dated=28-FEB-12
  'KSQL|San Carlos Airpo, California, USA|21|34|NW|', // lat=37.5167,long=-122.2500, elev=1, dated=28-FEB-12
  'KWVI|Watsonville, California, USA|27|44|SSE|', // lat=36.9333,long=-121.7833, elev=43, dated=28-FEB-12
  'KHWD|Hayward, California, USA|28|44|N|', // lat=37.6667,long=-122.1167, elev=21, dated=28-FEB-12
  'KSFO|San Francisco, California, USA|30|49|NW|', // lat=37.6167,long=-122.3667, elev=3, dated=28-FEB-12
  'KHAF|Half Moon Bay, California, USA|31|50|WNW|', // lat=37.5167,long=-122.5000, elev=21, dated=28-FEB-12
  'KOAK|Oakland, California, USA|31|50|NNW|', // lat=37.7000,long=-122.2167, elev=26, dated=28-FEB-12
  'KLVK|Livermore, California, USA|31|51|NNE|', // lat=37.7000,long=-121.8167, elev=117, dated=28-FEB-12
  'KCVH|Hollister Muni, California, USA|42|68|SE|', // lat=36.9000,long=-121.4167, elev=70, dated=28-FEB-12
  'KSNS|Salinas, California, USA|48|77|SSE|', // lat=36.6667,long=-121.6000, elev=30, dated=28-FEB-12
  'KMRY|Monterey, California, USA|49|78|SSE|', // lat=36.5833,long=-121.8500, elev=66, dated=28-FEB-12
  'KCCR|Concord, California, USA|50|81|N|', // lat=38.0000,long=-122.0500, elev=11, dated=28-FEB-12
// list generated Wed, 09-Jan-2013 4:39pm PST at
$maxAge = 75*60; // max age for metar in seconds = 75 minutes
$SITE['cacheFileDir']   =  './cache/';   // directory to use for scripts cache files .. use './' for doc.root.dir
$SITE['tz'] 			= 'America/Los_Angeles'; //NOTE: this *MUST* be set correctly to
// translate UTC times to your LOCAL time for the displays.
//  has the list of timezone names
//  pick the one that is closest to your location and put in $SITE['tz'] like:
//    $SITE['tz'] = 'America/Los_Angeles';  // or
//    $SITE['tz'] = 'Europe/Brussels';
$SITE['timeFormat'] = 'D, d-M-Y g:ia T';  // Day, 31-Mar-2006 6:35pm Tz  (USA Style)
$SITE['latitude']		= '37.27153397';    //North=positive, South=negative decimal degrees
$SITE['longitude']		= '-122.02274323';  //East=positive, West=negative decimal degrees

$condIconDir = './metar-images/';  // directory for metar-images with trailing slash
$SITE['fcsticonstype'] = '.jpg'; // default type='.jpg' 
#                                // use '.gif' for animated icons from #
$SITE['uomTemp'] = '°F';  // ='°C', ='°F'
$SITE['uomBaro'] = ' inHg';   // =' hPa', =' inHg'
$SITE['uomWind'] = ' mph';    // =' km/h', =' mph'
$SITE['uomRain'] = ' in';     // =' mm', =' in'
$SITE['uomDistance'] = ' mi'; // =' mi' or =' km'
// end of customizations


$MetarList = array( ... );
This array of elements controls which METAR sites will be displayed. Generate this list from the find-metar utility and copy the customized output to replace the contents of the sample above.
This is the number of seconds to use to determine the maximum age of the METAR report to display. The default is 75*60 = 75 minutes (which is reasonable given that METAR observations are usually posted hourly).
This specifies the directory to use to store the raw METAR observations. The default is './cache/'.
This specifies the valid PHP timezone to use. Visit for the proper value for your timezone.
This specifies the output format for the times displayed. Use the PHP date format descriptors to change this.
The decimal latitude of your location. use positive number for Northern Hemisphere and negative number for Southern Hemisphere.
The decimal longitude of your location. Use positive number for East of GMT (Europe, etc) and negative number for West of GMT (Americas, etc).
This specifies the relative location of the metar-images directory. Default is './metar-images/'
This specifies the type of icon to use. Default is '.jpg' for the NOAA-style picture condition icons. Use '.gif' for the animated GIF icons from
This specifies the units for temperature display. Valid values are:
='°C' for Centigrade (will also cause cloud heights to display in meters)
='&deg:F' for Fahrenheit (will also cause cloud heights to display in feet and temperatures in both F and C)
This specifies the units for barometric pressure. Valid values are:
=' hPa' for hecto-Pascals (World) (display only hPa )
=' inHg' for inches of mercury (USA) (will result in dual inHg and hPa displays)
This specifies the units for wind speed. Valid values are:
=' km/h' for kilometers-per-hour (World) (will result in km/h only displays)
=' mph' for miles-per-hour (USA,UK) (will result in dual mph and km/h displays)
This specifies the units for precipitation (not reported by METAR stations, but included for completeness). Valid values are:
=' mm' for millimeters
=' in' for inches
This specifies the units for distance (used for visibility reporting). Valid values are:
=' km' for kilometers (will result in km-only displays)
=' mi' for miles. (will result in dual mi and km displays)

The metar-display package (V1.03 - 30-Nov-2018):
demo | download .zip package

Version history

  • Version 1.03 - 30-Nov-2018 - updated get-metar-conditions-inc.php V1.17 for https to site, minor Notice errata fixes
  • Version 1.02 - 11-Oct-2017 - updated get-metar-conditions-inc.php V1.16 to use curl for fetch, fix fractional visibility calculation for kilometers
  • Version 1.01 - 23-May-2016 - updated get-metar-conditions-inc.php V1.13 for NWS website change
  • Version 1.00 - 09-Jan-2013 - Initial release