Weather station scripts - USGS earthquakes

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 and saratogaWXPHP Twitter account 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 Wednesday, 02-Sep-2009 9:38 AM

PHP Scripts (run on webserver)

These scripts have run on PHP 4.1.2, and PHP 4.4.1. I don't have access to PHP 3.x, so it is not known if they will work on versions below PHP 4.1.2. If you try them and they work (or not) on earlier versions of PHP, please send me a message at webmaster[at]saratoga-weather.org and let me know the results.

Recent nearby earthquakes (from USGS, NRC, BGS) PHP

Here in California, we're a bit sensitive to the earth moving (it happens a lot), so I wrote a PHP page to get, cache and reformat the last 7 days of earthquake information so it can be included on the website with links to additional info.

The output of these scripts is XHTML 1.0-Strict compliant. All of them use the same style for inclusion into your webpage as shown in the example below.

Here is a live example using quake-CANV.php):

<?php $doIncludeQuake = true; include("quake-CANV.php); ?>

produces the following:

Earthquakes of magnitude 2.0 or greater within 150 miles
Update time = Fri, 30-Jul-2010 2:00pm PDT
Near CityMagnitudeDistance to
Epicenter
Local TimeLink to
Map
4 km ( 3 mi) E of The Geysers, CA 2.2 113 mi (181 km) Fri, 30-Jul-2010 7:50am PDT map
10 km ( 6 mi) SE of Cantua Creek, CA 2.9 115 mi (184 km) Fri, 30-Jul-2010 6:19am PDT map
10 km ( 6 mi) SE of Cantua Creek, CA 2.4 114 mi (184 km) Fri, 30-Jul-2010 5:55am PDT map
11 km ( 7 mi) SE of Cantua Creek, CA 2.9 115 mi (185 km) Fri, 30-Jul-2010 3:56am PDT map
4 km ( 3 mi) W of Cobb, CA 2.0 115 mi (186 km) Fri, 30-Jul-2010 2:29am PDT map
11 km ( 7 mi) ESE of Cantua Creek, CA 2.6 115 mi (185 km) Thu, 29-Jul-2010 9:47pm PDT map
2 km ( 1 mi) NNE of The Geysers, CA 2.1 114 mi (184 km) Thu, 29-Jul-2010 10:34am PDT map
4 km ( 2 mi) N of The Geysers, CA 2.0 116 mi (186 km) Thu, 29-Jul-2010 9:33am PDT map
2 km ( 2 mi) NNE of The Geysers, CA 3.3 115 mi (185 km) Wed, 28-Jul-2010 3:37pm PDT map
12 km ( 8 mi) SW of Lake Nacimiento, CA 2.0 124 mi (200 km) Wed, 28-Jul-2010 11:47am PDT map
14 km ( 9 mi) S of Tres Pinos, CA 2.0 58 mi (94 km) Wed, 28-Jul-2010 7:34am PDT map
6 km ( 3 mi) SW of Laguna West-Lakeside, CA 2.4 82 mi (132 km) Wed, 28-Jul-2010 4:37am PDT map
1 km ( 1 mi) SE of The Geysers, CA 2.0 113 mi (182 km) Tue, 27-Jul-2010 7:18pm PDT map
3 km ( 2 mi) ESE of The Geysers, CA 2.0 113 mi (181 km) Mon, 26-Jul-2010 12:00pm PDT map
12 km ( 7 mi) NW of Pinnacles, CA 2.0 63 mi (102 km) Sun, 25-Jul-2010 7:17pm PDT map
12 km ( 8 mi) NW of Pinnacles, CA 2.6 63 mi (101 km) Sun, 25-Jul-2010 4:46pm PDT map
7 km ( 5 mi) NE of Alum Rock, CA 2.2 17 mi (28 km) Sat, 24-Jul-2010 3:26pm PDT map
2 km ( 2 mi) NNE of The Geysers, CA 2.1 115 mi (185 km) Sat, 24-Jul-2010 2:06pm PDT map
4 km ( 2 mi) N of The Geysers, CA 2.0 116 mi (187 km) Sat, 24-Jul-2010 8:33am PDT map
5 km ( 3 mi) SW of Daly City, CA 3.2 38 mi (61 km) Fri, 23-Jul-2010 2:29pm PDT map

Click on location for more details from the USGS.

The California/Nevada earthquake script : demo and download [ see version history ]
Documentation on how to customize the script is in comments contained in the source. For anywhere in California or Nevada, you just have to change $myLat and $myLong to your station's decimal latitude and longitude to see it work in your area. Defaults are for magnitude 2.5 (or greater) within a 150 mile radius.

The Canada earthquake script : demo and download [ see version history ]
Documentation on how to customize the script is in comments contained in the source. For anywhere in Canada, you just have to change $myLat and $myLong to your station's decimal latitude and longitude to see it work in your area. Defaults are for magnitude 2.0 (or greater) within a 500 km radius. This script uses data from Natural Resources Canada website and returns earthquake activity over the last 30 days. Version 1.03 now provides both English and French display.

The UK earthquake script : demo and download [ see version history ]
Documentation on how to customize the script is in comments contained in the source. For anywhere in the United Kingdom, you just have to change $myLat and $myLong to your station's decimal latitude and longitude to see it work in your area. Defaults are for earthquakes within a 500 km radius. This script uses data from British Geological Survey website and returns earthquake activity over the last 30 days.
BGS data is used with permission as long as the attribution built into the script displays with the script output.

The USA earthquake script : download [ see version history ]
Documentation on how to customize the script is in comments contained in the source. This script uses the USGS USA website, and has the last 7 days of earthquakes 1.0+ in magnitude for the lower 48 states, Alaska, Hawaii, parts of lower Canada, parts of upper Mexico and areas near Puerto Rico.
Demo for quakes near:
Saratoga, CA | Hilo, Hawaii | Anchorage, AK | Seattle, WA | St. Louis, MO | San Juan, Puerto Rico

The WORLD earthquake script : download [ see version history ]
Documentation on how to customize the script is in comments contained in the source. This script uses the USGS world website and has the last 7 days of earthquake data.
For the USA (48 lower states, Alaska, Hawaii, Puerto Rico) it has data on 2.5+ magnitude earthquakes.
For non-USA locations it has data on 4.0+ magnitude earthquakes.
Demo for quakes near:
Grahams Beach, NZ | Tokyo, Japan | Mexico City, Mexico | Tehran, Iran | Jakarta, Indonesia | Athens, Greece

In addition to the $myLat and $myLong changes, you will need to customize the scripts with the timezone information for your location. The source for each of the scripts has information on how to do this, and you can use this timezone name table to help select the correct zone name.