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.

Many of these scripts are now available on GitHub at https://github.com/ktrue

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 Sunday, 27-May-2018 2:25 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: Version 2.00 of the script replaced Google maps with Leaflet/OpenStreetMaps scripts, so you no longer need a Google API key (or any API key to use the 5 included maps with the script.

If you wish to use the OPTIONAL Mapbox.com tiles (terrain3, Satellite maps), you will need a Mapbox.com API key (called an "Access Token") which can be acquired (for free with 50K accesses usage/month) at:

https://www.mapbox.com/signup/?

in the quakes.php script you can put

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

Note: if using the Saratoga template set, put a new entry in Settings.php

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

A Mapbox API key is OPTIONAL .. you do not need it to use maps from 5 included free map tile providers.

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, 20-Oct-2019 6:38am PDT

Epicenter Near Magnitude Distance to Epicenter Time Link
1 mi NW of The Geysers, CA 2.0 000180112 mi 1571576777Sun, 20-Oct-2019 6:06am PDT map
5 mi NW of Pinnacles, CA 2.0 00010566 mi 1571567306Sun, 20-Oct-2019 3:28am PDT map
2 mi NNW of The Geysers, CA 2.1 000182113 mi 1571567123Sun, 20-Oct-2019 3:25am PDT map
2 mi NNE of Dublin, CA 2.7 00005233 mi 1571562834Sun, 20-Oct-2019 2:13am PDT map
10 mi SW of Toms Place, CA 2.9 000284176 mi 1571557850Sun, 20-Oct-2019 12:50am PDT map
2 mi W of Cupertino, CA 2.8 0000074 mi 1571504764Sat, 19-Oct-2019 10:06am PDT map
4 mi N of Diablo, CA 2.4 00006843 mi 1571503215Sat, 19-Oct-2019 9:40am PDT map
7 mi SE of Talmage, CA 2.1 000218136 mi 1571496398Sat, 19-Oct-2019 7:46am PDT map
7 mi SE of Talmage, CA 2.8 000219136 mi 1571496225Sat, 19-Oct-2019 7:43am PDT map
10 mi NW of Pinnacles, CA 2.0 00009861 mi 1571466648Fri, 18-Oct-2019 11:30pm PDT map
6 mi WNW of Pinnacles, CA 2.0 00010565 mi 1571442536Fri, 18-Oct-2019 4:48pm PDT map
16 mi NW of Hawthorne, Nevada 2.3 000318197 mi 1571437706Fri, 18-Oct-2019 3:28pm PDT map
6 mi WNW of The Geysers, CA 2.2 000186116 mi 1571428805Fri, 18-Oct-2019 1:00pm PDT map
3 mi NNE of Pinnacles, CA 2.7 00011269 mi 1571421754Fri, 18-Oct-2019 11:02am PDT map
15 mi SE of Pinnacles, CA 2.7 00013785 mi 1571419130Fri, 18-Oct-2019 10:18am PDT map
11 mi NW of Pinnacles, CA 2.0 00009760 mi 1571387911Fri, 18-Oct-2019 1:38am PDT map
4 mi E of Mammoth Lakes, CA 2.1 000278173 mi 1571370312Thu, 17-Oct-2019 8:45pm PDT map
18 mi SW of Hawthorne, Nevada 2.1 000300186 mi 1571340118Thu, 17-Oct-2019 12:21pm PDT map
10 mi NW of Pinnacles, CA 3.6 00009861 mi 1571324095Thu, 17-Oct-2019 7:54am PDT map
4 mi NW of The Geysers, CA 2.9 000185115 mi 1571321813Thu, 17-Oct-2019 7:16am PDT map
2 mi ENE of The Geysers, CA 2.7 000179111 mi 1571313495Thu, 17-Oct-2019 4:58am PDT map
4 mi WNW of The Geysers, CA 2.0 000184114 mi 1571296822Thu, 17-Oct-2019 12:20am PDT map
14 mi NE of San Ardo, CA 2.0 000165103 mi 1571262195Wed, 16-Oct-2019 2:43pm PDT map
14 mi NE of San Lucas, CA 2.1 00015797 mi 1571254450Wed, 16-Oct-2019 12:34pm PDT map
4 mi SSW of Gilroy, CA 2.2 00005232 mi 1571238889Wed, 16-Oct-2019 8:14am PDT map
3 mi SSW of Gilroy, CA 2.6 00005232 mi 1571232730Wed, 16-Oct-2019 6:32am PDT map
10 mi NW of Pinnacles, CA 3.3 00009760 mi 1571231353Wed, 16-Oct-2019 6:09am PDT map
2 mi ENE of Mammoth Lakes, CA 2.0 000274170 mi 1571229559Wed, 16-Oct-2019 5:39am PDT map
1 mi SSE of Spreckels, CA 2.3 00008251 mi 1571228897Wed, 16-Oct-2019 5:28am PDT map
6 mi ESE of Redwood Valley, CA 2.3 000238148 mi 1571225179Wed, 16-Oct-2019 4:26am PDT map
6 mi ESE of Lopez Point, CA 2.5 00015194 mi 1571219903Wed, 16-Oct-2019 2:58am PDT map
4 mi ENE of Coalinga, CA 2.0 000197123 mi 1571214341Wed, 16-Oct-2019 1:25am PDT map
10 mi NW of Pinnacles, CA 2.3 00009861 mi 1571212412Wed, 16-Oct-2019 12:53am PDT map
3 mi WNW of Cobb, CA 2.0 000186115 mi 1571211080Wed, 16-Oct-2019 12:31am PDT map
9 mi SSE of Mammoth Lakes, CA 2.0 000278173 mi 1571209416Wed, 16-Oct-2019 12:03am PDT map
9 mi SSE of Mammoth Lakes, CA 2.5 000279173 mi 1571195689Tue, 15-Oct-2019 8:14pm PDT map
9 mi SSE of Tres Pinos, CA 2.2 00009559 mi 1571195534Tue, 15-Oct-2019 8:12pm PDT map
10 mi NW of Pinnacles, CA 2.1 00009861 mi 1571195047Tue, 15-Oct-2019 8:04pm PDT map
9 mi SSE of Tres Pinos, CA 2.8 00009559 mi 1571194625Tue, 15-Oct-2019 7:57pm PDT map
9 mi SSE of Tres Pinos, CA 2.5 00009559 mi 1571193669Tue, 15-Oct-2019 7:41pm PDT map
0 mi WNW of Pleasant Hill, CA 3.2 00007547 mi 1571191918Tue, 15-Oct-2019 7:11pm PDT map
11 mi NW of Pinnacles, CA 2.1 00009760 mi 1571182917Tue, 15-Oct-2019 4:41pm PDT map
9 mi NW of Pinnacles, CA 2.3 00009962 mi 1571175082Tue, 15-Oct-2019 2:31pm PDT map
9 mi SSE of Tres Pinos, CA 2.6 00009559 mi 1571169346Tue, 15-Oct-2019 12:55pm PDT map
11 mi SSE of Tres Pinos, CA 4.7 00009760 mi 1571168550Tue, 15-Oct-2019 12:42pm PDT map
7 mi NNE of Cambria, CA 2.2 000200124 mi 1571142452Tue, 15-Oct-2019 5:27am PDT map
2 mi NNW of Pinnacles, CA 2.7 00011069 mi 1571134783Tue, 15-Oct-2019 3:19am PDT map
3 mi NW of Redwood Valley, CA 2.0 000249155 mi 1571128247Tue, 15-Oct-2019 1:30am PDT map
1 mi SSW of Pleasant Hill, CA 2.6 00007446 mi 1571122505Mon, 14-Oct-2019 11:55pm PDT map
1 mi S of Pleasant Hill, CA 2.1 00007446 mi 1571122256Mon, 14-Oct-2019 11:50pm PDT map
6 mi NNW of Redwood Valley, CA 2.0 000254158 mi 1571120732Mon, 14-Oct-2019 11:25pm PDT map
1 mi SSE of Pleasant Hill, CA 2.0 00007446 mi 1571118699Mon, 14-Oct-2019 10:51pm PDT map
0 mi W of Pleasant Hill, CA 2.1 00007547 mi 1571118105Mon, 14-Oct-2019 10:41pm PDT map
1 mi SSE of Pleasant Hill, CA 4.5 00007446 mi 1571117622Mon, 14-Oct-2019 10:33pm PDT map
1 mi S of Pleasant Hill, CA 2.5 00007446 mi 1571117038Mon, 14-Oct-2019 10:23pm PDT map
5 mi W of Durham, CA 2.7 000265165 mi 1571035877Sun, 13-Oct-2019 11:51pm PDT map
12 mi NE of Morgan Hill, CA 2.6 00004528 mi 1571016328Sun, 13-Oct-2019 6:25pm PDT map
12 mi NE of Morgan Hill, CA 2.9 00004528 mi 1571009527Sun, 13-Oct-2019 4:32pm PDT map
7 mi S of Tres Pinos, CA 2.4 00009156 mi 1571000557Sun, 13-Oct-2019 2:02pm PDT map

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

Script by Saratoga-weather.org

This was invoked by using the following code:

<?php 
# settings -------------------------- 
  $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
  $setLatitude  = 37.2746251;    //North=positive, South=negative decimal degrees
  $setLongitude = -122.0229656;   //East=positive, West=negative decimal degrees
# The above settings are for saratoga-weather.org location
  $setLocationName = 'Saratoga, CA'; // city/town name for lat/long above 
#
  $setTimeZone = "America/Los_Angeles";  //NOTE: this *MUST* be set correctly to
# translate UTC times to your LOCAL time for the displays.
# Use http://www.php.net/manual/en/timezones.php to find the timezone suitable for
#  your location.

#  pick a format for the time to display ..uncomment one (or make your own)
# $setTimeFormat = 'D, Y-m-d H:i:s T';  // Fri, 2006-03-31 14:03:22 TZone
  $setTimeFormat = 'D, d-M-Y H:i:s T';  // Fri, 31-Mar-2006 14:03:22 TZone

  $setDoLinkTarget = false;   // =true; to have links open in new page, =false; for XHTML 1.0-Strict

	$mapProvider = 'Esri_WorldTopoMap'; // ESRI topo map - no key needed
# $setMapProvider = 'OSM';     // OpenStreetMap - no key needed
# $setMapProvider = 'Terrain'; // Terrain map by stamen.com - no key needed
# $setMapProvider = 'OpenTopo'; // OpenTopoMap.com - no key needed
# $setMapProvider = 'Wikimedia'; // Wikimedia map - no key needed
  
# $mapProvider = 'MapboxSat';  // Map by Mapbox.com - API KEY needed in $setMapboxAPIkey 
# $mapProvider = 'MapboxTer';  // Map by Mapbox.com - API KEY needed in $setMapboxAPIkey 
 $setMapboxAPIkey = '--mapbox-API-key--';  // use this for the API key to MapBox

  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 (V2.01 - 27-May-2018):
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