Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Schneider Electric
Community
Community
Notifications
close
  • Categories
  • Forums
  • Knowledge Center
  • Blogs
  • Ideas
  • Events & Webinars
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register

Contact Support

Close

Ask our Experts

Have a question related to our products, solutions or services? Get quick support on community Forums

Email Us

For Community platform-related support, please email us

New Community Ranking System
Our Community ranking system has recently been updated. You may notice changes in user rankings and receive system messages or notifications. If you have questions about how the new ranking works, please refer to the announcement post for more details (click here).

Python API - How to get Earthquake data into a Geo SCADA Map

Geo SCADA Knowledge Base

Access vast amounts of technical know-how and pro tips from our community of Geo SCADA experts.

Search in

Improve your search experience:

  • Exact phrase → Use quotes " " (e.g., "error 404")
  • Wildcard → Use * for partial words (e.g., build*, *tion)
  • AND / OR → Combine keywords (e.g., login AND error, login OR sign‑in)
  • Keep it short → Use 2–3 relevant words , not full sentences
  • Filters → Narrow results by section (Knowledge Base, Users, Products)
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select a Country

Please select a country to continue with beta search.

  • Home
  • Schneider Electric Community
  • Knowledge Center
  • Geo SCADA Knowledge Base
  • Python API - How to get Earthquake data into a Geo SCADA Map
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Labels
Top Labels
  • Alphabetical
  • database 32
  • Web Server and Client 31
  • WebX 19
  • Request Form 18
  • Lists, Events & Alarms 16
  • ViewX 15
  • Setup 12
  • Application Programming 12
  • Telemetry 8
  • Mimic Graphics 7
  • Events & Alarms 7
  • Lists 7
  • Downloads 6
  • Geo SCADA Expert 5
  • SCADA 5
  • IoT 5
  • Support 5
  • Security 5
  • Drivers and Communications 4
  • IEC 61131-3 Logic 3
  • 2025 3
  • DNP 3 3
  • Geo Scada 2
  • Trends and Historian 2
  • Python 2
  • Virtual ViewX 2
  • Archive 1
  • Architectures 1
  • PI 1
  • Python API 1
  • Driver Kit 1
  • Code 1
  • Historian 1
  • Updates 1
  • OPC-UA 1
  • Privacy Policy 1
  • ClearSCADA 1
  • Mobile 1
  • Maps and GIS 1
  • Releases 1
  • Templates and Instances 1
  • AVEVA 1
  • Tools & Resources 1
  • Web 1
  • Previous
  • 1 of 5
  • Next
Latest Blog Posts
  • Microsoft Update Testing - Archive
  • PI Integration
  • Python API - Q and A
  • Python API - Create a custom web site serving Geo SCADA data using Flask
  • Configuration Examples
Related Products
product field
Schneider Electric
EcoStruxure™ Geo SCADA Expert

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
sbeadle
sbeadle Champion
Champion
‎2025-11-26 07:32 AM
0 Likes
0
467
  • Bookmark
  • Subscribe
  • Email to a Friend
  • Printer Friendly Page
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2025-11-26 07:32 AM

Python API - How to get Earthquake data into a Geo SCADA Map

Originally published on Geo SCADA Knowledge Base by sbeadle | November 26, 2025 04:32 PM

📖 Home  

📖 Python article index  

 

The objective of this sample is to retrieve and display earthquake data onto a map. A basic query is used to the USGS web site to get all earthquakes globally for the past week - those above a certain magnitude. This data is placed into a table, and then a query is used to list location data to be displayed on a Geo SCADA Map Set item.

 

The code is listed here. An .sde file is attached to this article, which includes the code in a Python item, the Data Table and associated Map Set.

It would be simple to adapt and extend this code to:

  • Filter the locations to a specific area, and focus the map on that area
  • Scan the data for earthquakes over a specific magnitude and in a specific area, then raise an alarm if those criteria are met

Sample image - click to enlarge:

sbeadle_0-1764170899079.png

 

 

# Example: Get Earthquake Map Data
import geo_scada_types
from geoscada.lib.variant import *
from datetime import datetime, timedelta
from geoscada.client.interface_scx import InterfaceScx
from geoscada.client.types import QueryStatus
from typing import Optional
import unicodedata
# Allow program to write to its StdErr property
import sys

################################################################
# Web request library - needs you to run "pip install requests"
################################################################
import requests

def execute(program_path: str, program_name: str, trigger_type: geo_scada_types.ProgramTrigger, geo_scada_args: dict, connection: Optional[InterfaceScx], *args, **kwargs):
    # Find this program item
    ppath = connection.find_object(program_path)

    #############################################################
    # RUN SECTION - READ FROM WEB WRITE TO GEO SCADA
    #############################################################

    # Make the web request
    starttime = (datetime.now() - timedelta(days=7)).strftime("%Y-%m-%d%%20%H:%M:%S")
    endtime = datetime.now().strftime("%Y-%m-%d%%20%H:%M:%S")
    minmagnitude = 4.5
    base_url = f"https://earthquake.usgs.gov/fdsnws/event/1/query.geojson"
    # Parameters
    final_url = base_url + f"?starttime={starttime}&endtime={endtime}&minmagnitude={minmagnitude}&orderby=time"
    # Constrain by bounding box, e.g. this is the USA
    # &maxlatitude=50&minlatitude=24.6&maxlongitude=-65&minlongitude=-125
    
    # Get data in JSON
    earthquake_response = requests.get(final_url)
    earthquake_data = earthquake_response.json()

    # The following would be more efficient to keep existing records, purge old and insert new

    # Remove all previous records
    sqltext = f"DELETE FROM Earthquakes"
    print(sqltext)
    q = connection.prepare_query(sqltext, False)
    result = q.execute_sync()
    if result.status == QueryStatus.Succeeded:
        print(result.rows_affected)
    else:
        print(result.status, file=sys.stderr)

    # Get all records and insert each one
    index = 0
    while (index < len(earthquake_data["features"])):
        # Get parameters
        time = earthquake_data["features"][index]["properties"]["time"] #milliseconds
        timevalue = datetime.fromtimestamp(time/1000.0)
        mag = earthquake_data["features"][index]["properties"]["mag"]
        title = earthquake_data["features"][index]["properties"]["title"]
        title = unicodedata.normalize('NFC', title).encode('ascii', 'ignore')
        title = title.decode()
        lat = earthquake_data["features"][index]["geometry"]["coordinates"][1]
        long = earthquake_data["features"][index]["geometry"]["coordinates"][0]
        print(f"{mag}, {timevalue.strftime('%Y-%m-%d %H:%M:%S')}, {title}, {lat}, {long}")
    
        sqltext = f"INSERT INTO Earthquakes (timevalue, mag, title, lat, long) VALUES (TIMESTAMP('{timevalue.strftime("%Y-%m-%d %H:%M:%S")}'), {mag}, '{title}', {lat}, {long})"
        print(sqltext)
        q = connection.prepare_query(sqltext, False)
        result = q.execute_sync()
        if result.status == QueryStatus.Succeeded:
            print(result.rows_affected)
        else:
            print(result.status, file=sys.stderr)
        index += 1

    print("Success")

 

See below for the .sde file.

 

📖 Home  

📖 Python article index  

 

08 Get Earthquake Map Data.sde
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA

Author

Biography

sbeadle

Link copied. Please paste this link to share this article on your social media post.

  • Back to Blog
  • Newer Article
  • Older Article
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support

    Ask our Experts

    Have a question related to our products, solutions or services? Get quick support on community Forums

    Email Us

    For Community platform-related support, please email us

Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2026 Schneider Electric

Welcome!

Welcome to your new personalized space.

of

Explore