Weather station scripts - Images and Handlers

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, 06-Jan-2017 12:48 PM

Image handling scripts

Wind direction Icons

The following wind direction icons are 14x14 transparent GIF files:


Wind Direction Icons: download [ see version history ]

You can easily use these icons with the wind direction (example for Weather-Display) by using this PHP code:

$avgspd = "%avgspd%"; // average wind speed (current)
$dirlabel = "%dirlabel%"; // wind direction (NNE etc)
if (strip_units($avgspd) <= 0.1 ) { echo "Calm";
} else { ?><img src="./images/<?php echo $dirlabel; ?>.gif" height="14" width="14" title="Wind from <?php echo $dirlabel; ?>" alt="Wind from <?php echo $dirlabel; ?>" /> <?php echo $dirlabel; ?>@ <?php echo strip_units($avgspd); ?> mph<?php } ?>

// strip trailing units from a measurement
// i.e. '30.01 in. Hg' becomes '30.01'
function strip_units ($data) {
return $t[1];
} ?>

Resize Nexstorm.jpg and wasp2.png scripts

This script will resize the nexstorm.jpg graphic and cache the result. It is used on my lightning.php page to force the width of the image to be 640px max (so it fits in the layout of the website). The second script does the same for the WASP2 PNG image.

<img src="resize-nexstorm-image.php" alt="NexStorm Display" width="640" height="445" />
NexStorm Display

Resize Nexstorm JPG PHP script: download [ see version history ]

<img src="resize-wasp2-image.php" alt="Wide Area Storm Probe 2" width="640" height="562" />

Wide Area Storm Probe 2

Resize WASP-2 PNG PHP script: download [ see version history ]

Fetch/resize/cache NOAA Image of the Day script

This script will get and cache locally the NOAA Image of the Day, and download, resize and cache the image if it is updated on the NOAA server. I use it in my NOAA Image of the Day page.

This script uses three files for caching, so please make sure that they are writable by PHP so the script will operate properly. The cache files needed are:

  • IOD-page-cache.txt (used for cache storage of nnvl page HTML)
  • IOD-image-full.jpg (used for cache storage of full-size IOD image)
  • IOD-image.jpg (used for cache storage of current IOD image resized to new width/height)

If your installation of the script shows the error message of:

Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known

followed by a series of other error messages, it is likely due to your PHP not permitting a fopen() on an URL. To fix, create (or modify) a php.ini file in the document root of your website and insert the line

allow_url_fopen = on;

into the php.ini file, and upload to your website. That will allow the script to fetch the graphic image from the NOAA website.

Some installations have had a PHP error citing insufficient memory to perform the resizing operations. If you receive this, try putting

php_value memory_limit 32M

in your php.ini. That seems to be sufficient to process the largest image files seen to date.

The image is resized to 620x349px to fit in the WD/AJAX/PHP template narrow width style. The full-size image is 960x540 (low res version).

Note: Version 2.00+ uses the NNVL RSS Feed for data instead of trying to parse the main webpage. The RSS feed XML data is quite large, and may take some time (multiple seconds) to download on some webservers. The script now uses cURL for the RSS fetch and stream fopen() to transfer the graphic. Translation of the page text to ISO-8859-1 is now included. There are two new internal settings variables are now included to control timeout when access to the NNVL RSS feed is slow/failing:

$nnvl_connect_timeout = 4; // seconds for connection to nnvl website
$nnvl_transfer_timeout = 8; // seconds for overall transfer of the big RSS XML file

To use the script on your page:

<?php include_once("get-nnvl-iod.php"); ?>

Current snow cover in the eastern United States

Current snow cover in the eastern United States

Clear skies enabled the GOES East satellite to capture this view of current snow cover over the eastern United States on January 18, 2018. An active weather pattern combined with below-normal temperatures this winter have brought accumulating snow as far south as Mississippi and Alabama for the second time in less than six weeks. In this image, a faint swath of snow is visible across southern Alabama and western Georgia. Brighter white areas indicate greater snow depths, as seen in parts of Arkansas, southern Missouri, Indiana and Ohio. Significant snowfall remains conspicuously absent in parts of the mid-Atlantic, including the Washington, D.C. area, as snow-producing storms have frequently tracked to the north or south of the region this winter. Created by our partners at the Cooperative Institute for Research in the Atmosphere, the GOES East geocolor imagery enhancement displays geostationary satellite data in different ways depending on whether it is day or night. In daytime imagery (shown here), land and shallow-water features appear as they do in true-color imagery, while at night, the window infrared channel 13 and the traditional fog product are used to identify both ice and liquid water clouds, and are made partially transparent against a static city lights background.

HiRes Image

Courtesy of NOAA Environmental Visualization Laboratory

Fetch/Resize/Cache NOAA Image of the day PHP script (V2.02 - 06-Jan-2017): download [ see version history ]

Note: this script replaces the resize-NOAA-IOD.php script as the Image Of the Day has moved to a new website and the resize-NOAA-IOD.php would not work with the new website's presentation.