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 Monday, 04-Jul-2016 1:49 PM

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.

Note: As of 22-Jun-2016, you need a Google Browser JavaScript API KEY to run this script
Generate the key from the Google Console: https://developers.google.com/maps/documentation/javascript/get-api-key
then change quake-json.php (if not running in the Saratoga template):

$googleAPI = '-replace-this-with-your-API-key-here-';

if you are using the Saratoga template set, then just put a new entry in Settings.php with:

$SITE['googleAPI'] = '-replace-this-with-your-API-key-here-';

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 = Sun, 24-Jul-2016 9:34am PDT

Epicenter Near Magnitude Distance to Epicenter Local Time Link
1 mi NE of The Geysers, California 2.0 000180112 mi 1469333908Sun, 24-Jul-2016 4:18am map
14 mi NE of Gonzales, California 3.1 00009962 mi 1469291041Sat, 23-Jul-2016 4:24pm map
5 mi ENE of Willits, California 2.0 000263164 mi 1469228751Fri, 22-Jul-2016 11:05pm map
11 mi SSE of Ridgemark, California 2.9 00009458 mi 1469196075Fri, 22-Jul-2016 2:01pm map
8 mi SSE of Ridgemark, California 2.4 00008956 mi 1469186410Fri, 22-Jul-2016 11:20am map
15 mi ENE of Greenfield, California 2.4 00013282 mi 1469175720Fri, 22-Jul-2016 8:22am map
9 mi SSE of Ridgemark, California 2.0 00009056 mi 1469162791Fri, 22-Jul-2016 4:46am map
14 mi WNW of West Bishop, California 2.5 000297184 mi 1469149719Fri, 22-Jul-2016 1:08am map
9 mi SSE of Mammoth Lakes, California 2.3 000277172 mi 1469145836Fri, 22-Jul-2016 12:03am map
9 mi SSE of Mammoth Lakes, California 2.2 000277172 mi 1469133447Thu, 21-Jul-2016 8:37pm map
8 mi SSE of Mammoth Lakes, California 2.3 000278172 mi 1469133040Thu, 21-Jul-2016 8:30pm map
18 mi SSW of Hawthorne, Nevada 2.0 000309192 mi 1469120235Thu, 21-Jul-2016 4:57pm map
9 mi SSE of Mammoth Lakes, California 2.0 000278172 mi 1469103611Thu, 21-Jul-2016 12:20pm map
4 mi WNW of The Geysers, California 2.0 000184115 mi 1469102265Thu, 21-Jul-2016 11:57am map
12 mi NNE of Upper Lake, California 2.4 000239148 mi 1469101848Thu, 21-Jul-2016 11:50am map
17 mi SW of West Bishop, California 2.5 000299186 mi 1469088020Thu, 21-Jul-2016 8:00am map
8 mi SSE of Ridgemark, California 2.0 00009056 mi 1469082782Thu, 21-Jul-2016 6:33am map
16 mi NE of Hollister, California 2.0 00007849 mi 1469010976Wed, 20-Jul-2016 10:36am map
15 mi NE of Soledad, California 2.0 00011169 mi 1469006873Wed, 20-Jul-2016 9:27am map
1 mi SW of San Juan Bautista, California 2.2 00006440 mi 1468975665Wed, 20-Jul-2016 12:47am map
15 mi SSE of Mammoth Lakes, California 2.2 000282175 mi 1468975035Wed, 20-Jul-2016 12:37am map
15 mi SSE of Mammoth Lakes, California 2.5 000282175 mi 1468974848Wed, 20-Jul-2016 12:34am map
1 mi WSW of San Juan Bautista, California 2.9 00006439 mi 1468973284Wed, 20-Jul-2016 12:08am map
9 mi SSE of Ridgemark, California 2.9 00009056 mi 1468966444Tue, 19-Jul-2016 10:14pm map
5 mi ENE of Coalinga, California 2.1 000199124 mi 1468959973Tue, 19-Jul-2016 8:26pm map
8 mi SSE of Ridgemark, California 2.1 00008955 mi 1468948107Tue, 19-Jul-2016 5:08pm map
8 mi SSE of Ridgemark, California 2.3 00008955 mi 1468946623Tue, 19-Jul-2016 4:43pm map
8 mi SSE of Ridgemark, California 2.0 00008956 mi 1468940594Tue, 19-Jul-2016 3:03pm map
9 mi SSE of Ridgemark, California 2.9 00009056 mi 1468939695Tue, 19-Jul-2016 2:48pm map
8 mi NE of Chualar, California 3.9 00008855 mi 1468939160Tue, 19-Jul-2016 2:39pm map
8 mi SSE of Ridgemark, California 4.2 00008955 mi 1468939118Tue, 19-Jul-2016 2:38pm map
6 mi WNW of Cobb, California 2.0 000188117 mi 1468939006Tue, 19-Jul-2016 2:36pm map
15 mi SSE of Mammoth Lakes, California 2.1 000282175 mi 1468914424Tue, 19-Jul-2016 7:47am map
4 mi WSW of Gilroy, California 2.1 00004729 mi 1468908730Tue, 19-Jul-2016 6:12am map
16 mi NE of Hollister, California 3.1 00007848 mi 1468907389Tue, 19-Jul-2016 5:49am map
11 mi NE of San Martin, California 2.0 00005031 mi 1468888113Tue, 19-Jul-2016 12:28am map
2 mi NNW of Hollister, California 2.2 00006943 mi 1468866537Mon, 18-Jul-2016 6:28pm map
16 mi NE of Hollister, California 2.1 00007848 mi 1468864782Mon, 18-Jul-2016 5:59pm map
16 mi NE of Hollister, California 3.7 00007848 mi 1468808845Mon, 18-Jul-2016 2:27am map
8 mi SSE of Ridgemark, California 2.8 00008955 mi 1468799652Sun, 17-Jul-2016 11:54pm map
8 mi S of Ridgemark, California 2.9 00008855 mi 1468797310Sun, 17-Jul-2016 11:15pm map
9 mi SSE of Ridgemark, California 3.3 00008956 mi 1468797276Sun, 17-Jul-2016 11:14pm map
8 mi SSE of Ridgemark, California 2.3 00008955 mi 1468796808Sun, 17-Jul-2016 11:06pm map
8 mi SSE of Ridgemark, California 2.9 00008955 mi 1468796776Sun, 17-Jul-2016 11:06pm map
8 mi SSE of Ridgemark, California 2.7 00008955 mi 1468796631Sun, 17-Jul-2016 11:03pm map
8 mi SSE of Ridgemark, California 3.3 00008955 mi 1468796487Sun, 17-Jul-2016 11:01pm map
9 mi SSE of Ridgemark, California 2.0 00009056 mi 1468796194Sun, 17-Jul-2016 10:56pm map
8 mi SSE of Ridgemark, California 3.8 00009056 mi 1468796011Sun, 17-Jul-2016 10:53pm map
8 mi SSE of Ridgemark, California 2.3 00008955 mi 1468795068Sun, 17-Jul-2016 10:37pm map
8 mi SSE of Ridgemark, California 2.4 00008955 mi 1468794540Sun, 17-Jul-2016 10:29pm map
9 mi SSE of Ridgemark, California 3.1 00009056 mi 1468794372Sun, 17-Jul-2016 10:26pm map
4 mi ENE of San Simeon, California 2.9 000195121 mi 1468774751Sun, 17-Jul-2016 4:59pm map
2 mi WSW of Lemoore, California 2.2 000224139 mi 1468771156Sun, 17-Jul-2016 3:59pm map
14 mi WNW of West Bishop, California 2.4 000297184 mi 1468753300Sun, 17-Jul-2016 11:01am map

54 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.09 - 03-Jul-2016):
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