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 Tuesday, 30-May-2017 3:08 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 = Fri, 15-Dec-2017 9:27pm PST

Epicenter Near Magnitude Distance to Epicenter Time Link
2 mi NNW of Plumas Eureka, CA 2.7 000306190 mi 1513396518Fri, 15-Dec-2017 7:55pm PST map
4 mi WSW of Yountville, CA 2.1 00012879 mi 1513390669Fri, 15-Dec-2017 6:17pm PST map
2 mi SE of The Geysers, CA 2.0 000176109 mi 1513369648Fri, 15-Dec-2017 12:27pm PST map
2 mi NNW of Pinnacles, CA 3.4 00011068 mi 1513326245Fri, 15-Dec-2017 12:24am PST map
11 mi WSW of Corcoran, CA 2.6 000248154 mi 1513293716Thu, 14-Dec-2017 3:21pm PST map
8 mi WNW of Toms Place, CA 2.4 000285177 mi 1513289508Thu, 14-Dec-2017 2:11pm PST map
9 mi SW of Toms Place, CA 2.9 000285177 mi 1513230141Wed, 13-Dec-2017 9:42pm PST map
6 mi SSE of Elmira, CA 2.0 00011169 mi 1513229698Wed, 13-Dec-2017 9:34pm PST map
7 mi NNW of Coalinga, CA 2.1 000184114 mi 1513228561Wed, 13-Dec-2017 9:16pm PST map
6 mi S of Elmira, CA 2.5 00011169 mi 1513228485Wed, 13-Dec-2017 9:14pm PST map
11 mi WSW of Laytonville, CA 4.3 000296184 mi 1513227438Wed, 13-Dec-2017 8:57pm PST map
9 mi N of Coalinga, CA 2.1 000186116 mi 1513204608Wed, 13-Dec-2017 2:36pm PST map
8 mi N of Coalinga, CA 2.6 000186115 mi 1513204468Wed, 13-Dec-2017 2:34pm PST map
4 mi W of Cobb, CA 2.2 000186116 mi 1513200959Wed, 13-Dec-2017 1:35pm PST map
1 mi NNW of The Geysers, CA 2.0 000181112 mi 1513199664Wed, 13-Dec-2017 1:14pm PST map
30 mi W of Del Monte Forest, CA 2.4 00007949 mi 1513192053Wed, 13-Dec-2017 11:07am PST map
5 mi NW of The Geysers, CA 2.1 000187116 mi 1513180485Wed, 13-Dec-2017 7:54am PST map
6 mi ENE of San Martin, CA 2.3 00004830 mi 1513170907Wed, 13-Dec-2017 5:15am PST map
7 mi NW of Pinnacles, CA 2.7 00010264 mi 1513151579Tue, 12-Dec-2017 11:52pm PST map
18 mi SW of Hawthorne, Nevada 2.0 000301187 mi 1513104128Tue, 12-Dec-2017 10:42am PST map
4 mi SSE of Laytonville, CA 2.1 000291181 mi 1513024316Mon, 11-Dec-2017 12:31pm PST map
3 mi NW of The Geysers, CA 2.0 000184114 mi 1513022554Mon, 11-Dec-2017 12:02pm PST map
6 mi ENE of Gerber, CA 3.2 000315196 mi 1512974586Sun, 10-Dec-2017 10:43pm PST map
7 mi NW of Pinnacles, CA 2.0 00010263 mi 1512933394Sun, 10-Dec-2017 11:16am PST map
7 mi NW of Pinnacles, CA 2.1 00010263 mi 1512931365Sun, 10-Dec-2017 10:42am PST map
7 mi NW of Pinnacles, CA 2.5 00010263 mi 1512931169Sun, 10-Dec-2017 10:39am PST map
7 mi NW of Pinnacles, CA 2.5 00010263 mi 1512921949Sun, 10-Dec-2017 8:05am PST map
5 mi NNE of Clearlake, CA 2.1 000200124 mi 1512917078Sun, 10-Dec-2017 6:44am PST map
7 mi W of Toms Place, CA 2.1 000285177 mi 1512898234Sun, 10-Dec-2017 1:30am PST map
2 mi NNE of Pismo Beach, CA 2.2 000265165 mi 1512875048Sat, 09-Dec-2017 7:04pm PST map
17 mi WSW of Hawthorne, Nevada 2.0 000301187 mi 1512874916Sat, 09-Dec-2017 7:01pm PST map
2 mi S of Boonville, CA 2.3 000223138 mi 1512863352Sat, 09-Dec-2017 3:49pm PST map
2 mi S of Anderson Springs, CA 2.5 000174108 mi 1512836164Sat, 09-Dec-2017 8:16am PST map
7 mi W of Toms Place, CA 2.2 000286178 mi 1512803354Fri, 08-Dec-2017 11:09pm PST map
7 mi W of Toms Place, CA 2.3 000285177 mi 1512797412Fri, 08-Dec-2017 9:30pm PST map

35 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.13 - 30-May-2017):
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|Time|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