deformed-offering

Weather station scripts - USGS earthquakes

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 WXForum.net and Weather-Watch forums and saratogaWXPHP Twitter account as they become available.

This page was updated Saturday, 06-Jul-2013 9:11 AM

PHP Scripts (run on webserver)

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 scripts 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.

The USA/World earthquake script uses the new USGS GeoJSON feed for data and provides information on USA quakes of 1.0+ magnitude and Worldwide quakes of 4.0+ magnitude. This script is included in the AJAX/PHP Base-USA and Base-World template sets. Sample output with USA settings:

Earthquakes in the past 7 days of magnitude 2.0 or greater within 200 mi
Update time = Mon, 01-Sep-2014 9:12pm PDT

Epicenter Near Magnitude Distance to Epicenter Local Time Link
6 mi ESE of Gilroy, California 2.0 00005936 mi 1409618798Mon, 01-Sep-2014 5:46pm map
3 mi SSW of Yountville, California 2.6 00012578 mi 1409602500Mon, 01-Sep-2014 1:15pm map
14 mi WSW of Inverness, California 2.3 00012980 mi 1409601324Mon, 01-Sep-2014 12:55pm map
6 mi ESE of Gilroy, California 2.1 00005937 mi 1409590243Mon, 01-Sep-2014 9:50am map
6 mi ESE of Gilroy, California 2.4 00005937 mi 1409589417Mon, 01-Sep-2014 9:36am map
6 mi ESE of Gilroy, California 3.5 00005937 mi 1409587837Mon, 01-Sep-2014 9:10am map
2 mi NW of The Geysers, California 2.3 000184114 mi 1409550578Sun, 31-Aug-2014 10:49pm map
2 mi W of Tahoe Vista, California 2.0 000275171 mi 1409549945Sun, 31-Aug-2014 10:39pm map
2 mi W of American Canyon, California 2.4 00010465 mi 1409535674Sun, 31-Aug-2014 6:41pm map
2 mi ENE of Penngrove, California 2.0 00012879 mi 1409535648Sun, 31-Aug-2014 6:40pm map
2 mi WSW of American Canyon, California 2.1 00010263 mi 1409534051Sun, 31-Aug-2014 6:14pm map
30 mi NE of Mammoth Lakes, California 2.1 000309192 mi 1409495770Sun, 31-Aug-2014 7:36am map
6 mi W of Atascadero, California 2.0 000227141 mi 1409495153Sun, 31-Aug-2014 7:25am map
0 mi SSW of Green Valley, California 2.5 00010968 mi 1409492250Sun, 31-Aug-2014 6:37am map
9 mi SSE of Ridgemark, California 2.2 00009056 mi 1409490947Sun, 31-Aug-2014 6:15am map
5 mi SSW of Napa, California 3.2 00011069 mi 1409475380Sun, 31-Aug-2014 1:56am map
5 mi SW of Napa, California 2.3 00011269 mi 1409466335Sat, 30-Aug-2014 11:25pm map
14 mi NE of Gonzales, California 2.7 00009962 mi 1409460520Sat, 30-Aug-2014 9:48pm map
0 mi SW of Green Valley, California 2.4 00010968 mi 1409457407Sat, 30-Aug-2014 8:56pm map
5 mi SW of Napa, California 2.0 00011269 mi 1409451043Sat, 30-Aug-2014 7:10pm map
4 mi WNW of Cobb, California 2.0 000187116 mi 1409445882Sat, 30-Aug-2014 5:44pm map
2 mi SW of Yountville, California 2.0 00012679 mi 1409437282Sat, 30-Aug-2014 3:21pm map
9 mi SSE of Ridgemark, California 2.2 00009056 mi 1409430777Sat, 30-Aug-2014 1:32pm map
7 mi NNE of San Simeon, California 2.1 000188117 mi 1409399127Sat, 30-Aug-2014 4:45am map
2 mi NW of The Geysers, California 2.1 000183114 mi 1409378817Fri, 29-Aug-2014 11:06pm map
9 mi SSE of Ridgemark, California 2.4 00009156 mi 1409357207Fri, 29-Aug-2014 5:06pm map
9 mi SSE of Ridgemark, California 3.4 00009056 mi 1409355125Fri, 29-Aug-2014 4:32pm map
9 mi SSE of Ridgemark, California 2.1 00009056 mi 1409354865Fri, 29-Aug-2014 4:27pm map
9 mi SSE of Ridgemark, California 2.3 00009056 mi 1409352462Fri, 29-Aug-2014 3:47pm map
9 mi SSE of Ridgemark, California 2.2 00009056 mi 1409351956Fri, 29-Aug-2014 3:39pm map
3 mi WNW of American Canyon, California 2.4 00010666 mi 1409351680Fri, 29-Aug-2014 3:34pm map
4 mi NW of The Geysers, California 2.7 000186115 mi 1409349198Fri, 29-Aug-2014 2:53pm map
9 mi SSE of Ridgemark, California 3.0 00009056 mi 1409348656Fri, 29-Aug-2014 2:44pm map
3 mi E of Orange Cove, California 2.5 000257160 mi 1409323716Fri, 29-Aug-2014 7:48am map
5 mi SW of Napa, California 2.1 00011169 mi 1409285773Thu, 28-Aug-2014 9:16pm map
4 mi SW of Napa, California 2.2 00011169 mi 1409263516Thu, 28-Aug-2014 3:05pm map
22 mi NW of San Simeon, California 2.2 000163101 mi 1409256057Thu, 28-Aug-2014 1:00pm map
4 mi NW of American Canyon, California 2.4 00010867 mi 1409236073Thu, 28-Aug-2014 7:27am map
0 mi SSE of Green Valley, California 2.2 00011068 mi 1409234722Thu, 28-Aug-2014 7:05am map
14 mi NE of Soledad, California 2.0 00011370 mi 1409232119Thu, 28-Aug-2014 6:21am map
3 mi SE of Calistoga, California 2.2 00014992 mi 1409228121Thu, 28-Aug-2014 5:15am map
4 mi NW of The Geysers, California 2.0 000184115 mi 1409184804Wed, 27-Aug-2014 5:13pm map
5 mi SW of Napa, California 2.6 00011269 mi 1409165839Wed, 27-Aug-2014 11:57am map
6 mi E of Mammoth Lakes, California 2.2 000282175 mi 1409161695Wed, 27-Aug-2014 10:48am map
4 mi WNW of The Geysers, California 2.6 000185115 mi 1409150524Wed, 27-Aug-2014 7:42am map
4 mi SW of Napa, California 2.2 00011370 mi 1409148495Wed, 27-Aug-2014 7:08am map
7 mi NNW of Healdsburg, California 2.2 000178111 mi 1409135795Wed, 27-Aug-2014 3:36am map
4 mi SW of Napa, California 2.0 00011270 mi 1409110583Tue, 26-Aug-2014 8:36pm map
1 mi ESE of Berkeley, California 2.1 00006943 mi 1409102346Tue, 26-Aug-2014 6:19pm map
2 mi W of American Canyon, California 2.1 00010464 mi 1409095620Tue, 26-Aug-2014 4:27pm map
14 mi ENE of Soledad, California 2.6 00011571 mi 1409080544Tue, 26-Aug-2014 12:15pm map
5 mi SW of Napa, California 2.5 00011169 mi 1409075811Tue, 26-Aug-2014 10:56am map
16 mi WSW of Coalinga, California 2.2 000187116 mi 1409072705Tue, 26-Aug-2014 10:05am map
5 mi SW of Napa, California 2.0 00011169 mi 1409070947Tue, 26-Aug-2014 9:35am map
4 mi SW of Napa, California 3.0 00011269 mi 1409060752Tue, 26-Aug-2014 6:45am map
2 mi W of American Canyon, California 2.8 00010465 mi 1409058739Tue, 26-Aug-2014 6:12am map
2 mi W of American Canyon, California 2.7 00010465 mi 1409056552Tue, 26-Aug-2014 5:35am map
2 mi W of American Canyon, California 3.9 00010464 mi 1409056396Tue, 26-Aug-2014 5:33am map
3 mi SSW of Yountville, California 2.0 00012577 mi 1409053402Tue, 26-Aug-2014 4:43am map
2 mi NW of The Geysers, California 2.0 000184114 mi 1409032032Mon, 25-Aug-2014 10:47pm map
1 mi SE of Deer Park, California 2.1 00014490 mi 1409030767Mon, 25-Aug-2014 10:26pm map
17 mi NE of King City, California 2.0 00013483 mi 1409028595Mon, 25-Aug-2014 9:49pm map

62 earthquakes found. Click on location or map links for more details from the USGS

This was invoked by using the following code:

<?php 
  $doIncludeQuake = true;
# uncomment ONE of the $setDistanceDisplay lines to use as template for distance displays  
#  $setDistanceDisplay = 'mi (km)';
  $setDistanceDisplay = 'mi';
#  $setDistanceDisplay = 'km (mi)';
#  $setDistanceDisplay = 'km';

  $setDistanceRadius  = 200;  // same units as first unit in $setDistanceDisplay
# NOTE: quakes of magnitude 1.0+ are available for USA locations only.
#    non-USA location earthquakes of magnitude 4.0+ are the only ones available from the USGS
  $setMinMagnitude = '2.0';  // minimum Richter Magnitude to display
  $setHighMagnitude = '4.0';  // highlight this Magnitude and greater
  
  $setMapZoomDefault = 7;    // default zoom for Google Map 1=world to 13=street
# script will use your $SITE[] values for latitude, longitude, timezone and time display format
  include_once("quake-json.php");
  ?>

Also required is the styling and JavaScript <script> statements in the <head>...</head> part of the page (see the sample quakes.php page in the distribution quake-json.zip package for details).

The USGS GeoJSON earthquake script (V1.05 - 24-May-2013):
demo | download .zip package | download script only [ see version history ]

This script loads the GeoJSON feed for all earthquakes in the last 7 days from the USGS. For the USA, magnitude 1.0+ quakes are available. For non-USA locations, the USGS only provides information on magnitude 4.0+ based on the data they receive from partner seismographic organizations. If you are installing the script for standalone use, do download the .ZIP package as it contains the graphics files needed for the Google Map. If you are using the AJAX/PHP template set (V3+), the script is already integrated into the Base-USA and Base-World templates.

For Base-World template users, the script is compatible with the language translation features of the template set. You may need to add to your language-LL.txt translation file the following entries (translated) in order to show the ouput in language LL.
Note: the |of| entry below is used in the reports for quake location as in:
  20 mi NNW of Saratoga, California

langlookup|Update time|Update time|
langlookup|of|of|
langlookup|No earthquakes of magnitude|No earthquakes of magnitude|
langlookup|or greater within|or greater within|
langlookup|reported in last 7 days|reported in last 7 days|
langlookup|Cluster - click to expand details|Cluster - click to expand details|
langlookup|Enable JavaScript to view the Google Map.|Enable JavaScript to view the Google Map.|
langlookup|Earthquakes in the past 7 days of magnitude|Earthquakes in the past 7 days of magnitude|
langlookup|or greater within|or greater within|
langlookup|Epicenter Near|Epicenter Near|
langlookup|Magnitude|Magnitude|
langlookup|Distance to Epicenter|Distance to Epicenter|
langlookup|Local Time|Local Time|
langlookup|Link|Link|
langlookup|map|map|
langlookup|Note: Click on column heading marked with|Note: Click on column heading marked with|
langlookup|to sort column contents.|to sort column contents.|
langlookup|earthquakes found. Click on location or map links for more details from the <a href="http://earthquake.usgs.gov/earthquakes/map/">USGS</a>|earthquakes found. Click on location or map links for more details from the <a href="http://earthquake.usgs.gov/earthquakes/map/">USGS</a>|
langlookup|Depth|Depth|
langlookup|Distance to epicenter|Distance to epicenter|
langlookup|Map and data courtesy of|Map and data courtesy of|
langlookup|United States Geological Survey|United States Geological Survey|

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.

Deprecated Scripts

With the release of quake-json.php script on 8-Sep-2012, the following scripts are no longer maintained as the USGS is deprecating the pages on their website that these scripts require:

  • quake-CANV.php
  • quake-USA.php
  • quake-WORLD.php and quake-WORLD-ML.php

The quake-json.php script uses the USGS new GeoJSON feed for 1+ (USA) and 4+ (World) magnitude events and replaces the functionality of the above scripts.

deformed-offering