Weather station scripts

They're free, but use at your own risk

The scripts in PHP and Perl 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 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 small 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 WXForum.net and Weather-Watch forums as they become available.

Latest postings about Saratoga-weather.org Weather PHP scripts on Twitter

follow Saratoga-Weather.org PHP script updates on Twitter

This page was updated Tuesday, 01-Sep-2009 7:56 PM

Carterlake-style Wunderground USA Radar/Maps PHP

Thanks to Tom at Carter Lake, many folks have downloaded and adapted his Weather Underground Radar/Maps display. The script produces a great display of current radar and maps, but has required fairly expert HTML coding to adapt to your own website. Thanks to additions and modifications made by Jim at Juneau County Weather, new maps and highlighting features were added. This script builds on the work of both Tom and Jim to (hopefully) provide a comprehensive AND easy-to-configure PHP script to display the great radar and maps available on Weather Underground.
PLEASE NOTE: This script only works for locations in the continental US (lower 48 states).

Legal Stuff -- please read and heed...

This script generates URLs to radar/map images from WeatherUnderground.com, which contains copyrighted material. WU has a very stringent (and somewhat strident) Terms of Use that on first reading seems to prohibit any usage of their site, even by personal, non-commercial websites who's owners are contributing their weather data to Weather Underground. The ToS seems to prohibit even the common usage by VWS templates (and my AJAXed versions) which make extensive use of WU forecast, radar/map graphics and data in their design.

In a series of mail messages and forum postings, the intent of WU is to allow fair usage of their graphics and data for personal, non-commercial stations that contribute data to WeatherUnderground was stated. Here's the message with that information:

Hello,

My name is John Celenza and I am the Director of Weather Technology at Wunderground.

Please let me explain.

It is not Weather Underground's intention to disallow folks to use our graphics and data on their personal/non-commercial web sites.

Please feel free to use Wunderground images and data on personal sites, as long as you link those images to Wunderground or give direct credit. Something like "This image courtesy of Weather Underground" is appropriate.

We sincerely appreciate the contributions folks have made to our community. And, we are in no way an organization trying to take...take...take and not give. Our philosophy couldn't be farther from that.

Hopefully we can make the Terms of Service more clear soon.

Thank you!

-John

So, in order to use this script you need to:

  1. Have your weather station submit data to WeatherUnderground as a WU member.
  2. Use this script ONLY on your personal, non-commercial weather station website.
  3. Leave attribution (and hotlink) to WeatherUnderground as the source of the data.

Adhere to these three requirements, and you should have fair use of this data from Weather Underground.

Sample output

Show Normal View | Show with Configuration Aid enabled

Zoom:  Zoom In  City Level  South SF Bay SF Bay Area Southwest US Entire US Zoom Out Animated: OFF   Advisories: OFF   Track: OFF   Lightning: OFF
• Saratoga
  Additional Weather Maps   
Fronts    Jet Stream    Vis Sat    IR Sat    Wind    Temperatures    Humidity    Dew Point   
Heat Index    Wind Chill    Snow Depth    Visibility    Air Quality    UV    Flu   
 
Radar and map images courtesy of Weather Underground.

Thanks to Tom at Carter Lake, Jim at Juneau County Weather and Ken at Saratoga-Weather for the display script for this page.

Settings in the WU-radar-inc.php script

// settings ----------------------------- */
$imagesDir = './ajax-images/';  // directory for ajax-images+radar buttons with trailing slash
$RDR  = 'MUX';  // last 3 characters of NOAA Radar Site Name
$Lat  = '37.27153397';    //North=positive, South=negative decimal degrees
$Long = '-122.02274323';  //East=positive, West=negative decimal degrees
$City = 'Saratoga';  // Name of city
$WUregion = 'sw';    // WeatherUnderground regional map group name
// 'sw'=SouthWest, 'nw'=NorthWest, 'mw'=Midwest
// 'sp'=South Central, 'ne'=North East, 'se'=South East
$WUname1	= 'City Level';		// tooltip label for mode=1
$WUname2	= 'South SF Bay';	// tooltip label for mode=2
$WUname3	= 'SF Bay Area';	// tooltip label for mode=3
$WUname4	= 'Southwest US';	// tooltip label for mode=4
$WUname5	= 'Entire US';		// tooltip label for mode=5
//
$imagesDir
This setting controls the directory location of the helper images used by the script. Default is ./ajax-images/.
$RDR
This is the last three characters of your selected NEXRAD Radar Site ID. My radar is KMUX, so the default shown above is MUX.
$myLat,$myLong
This is the latitude and longitude of your weather station in decimal degrees.
$City
This is the name of your City or Weather Station. It will appear overlaid on the maps as shown here.
$WUregion
This is the 2-character identifier for the 'region' of the USA your site is in. The six allowed values are shown in the comments above. All regional maps will use this as part of the image URL to Wunderground.
$WUname1 ... $WUname5
These variables specify the text to display as the mouse cursor is rolled across the zoom buttons at the top, left of the display. You should change $WUname2 ... $WUname4 to reflect the locale of your weather station.

The $CityURL and $MetroURL settings in the script control the pan/zoom for the local radar display (mode=1, mode=2) and need to be set up like this:

  1. Go to www.wunderground.com and search for your city, state, then click on the radar image.
  2. Draw a box around your 'metro area' .. the radar image on Wunderground will zoom in.
  3. Right click on 'View/Save this image' and copy URL to clipboard
  4. Paste the url from the clipboard into the $MetroURL = '...'; setting.
  5. draw a box on the Wunderground radar around your 'city area'
  6. right click on 'View/Save this image' and copy URL to clipboard
  7. paste the URL from the clipboard into the $CityURL = '...'; setting

The final part of the setup is to discover and store the relative position information for the red dot () to mark your City location over each map type. The $CityPosN variables are used to store the relative position information to place a red dot and $City over the map displayed. There are 9 different sizes of maps displayed. The $CityColorN variables are for the text color of the overlay city name display. '#FFFFFF' (white) should work for most displays, You may need to adjust $CityColor4 (advisory map) and/or $CityColor8 (Flu map) to a different color since they use white backgrounds.

Now run the WU-radar-testpage.php?show=loc on your website to enable the helper app. There are currently 9 different map topologies used in the display, so you'll need to repeat this process 9 times:

  1. Click on the $CityPos1 link shown on the page, then
  2. click the cross-hair cursor over the point where the red dot is to appear, and the legend will move to that location, and the PHP code will appear in a text box for copying new values.
  3. Highlight the text box on the page displaying
    $CityPos1 = 'left: nnnpx; top: -mmmpx';
  4. copy the contents to the clipboard, and paste it to replace the $CityPos1 line shown in the script.

Repeat the procedure for $CityPos2 through $CityPos9. Change the corresponding $CityColorN if need be to allow your city location to display over the map.

Now your copy of the script should be fully configured. Upload your changed copy of the script. It's now ready to include in your own webpage by using this code:

<php
include("WU-radar-inc.php");
?>

where you'd like the display to be placed.

Installation of WU-radar-inc.php

Download WU-radar.zip from the link below.

Unzip the file and upload the contents to your website. The helper graphics will be placed in ./ajax-images/ directory .

Change settings in WU-radar-inc.php as instructed in the settings area above.

Download: WU-radar-inc.php distribution (Version 1.05 - 24-Jul-2008)
Download: just the WU-radar-inc.php script.

Using this script on your website

Because of differences in rendering engines used in different browsers, you may find misplaced red-dot/city name overlays if you attempt to center the display on a page in your website. It may look fine in Firefox, but break terribly in Internet Explorer.

I recommend you NOT use <center></center>, <div align="center"></div>, trying to 'float' the display, or use it inside a table. None seem to satisfy IE. Using the code:

    <div style="background-color:#000000;color:#FFFFFF">
<?php include("WU-radar-inc.php"); ?>
</div>

seems to work the best for Firefox, IE, Opera and Safari-Win. If you really want to center the script, then Jim (Juneau County Weather) suggests using an <iframe> like this:

<div align="center">     
<iframe src="http://your.website.com/WU-radar-inc.php" width="660" height="740"
frameborder="0" 
style="background-color:#000000; color:#FFFFFF; font-family:Arial, Helvetica, sans-serif;"
 scrolling="no"></iframe> 
</div>