sensor-things-api-demo

BGS SensorThings API Demo

This repository provides examples for querying, visualising, and mapping environmental monitoring data from the British Geological Survey (BGS) Sensor Data Service, published via an OGC SensorThings API-compliant FROST-Server endpoint (https://sensors.bgs.ac.uk/FROST-Server/v1.1/).

Contents


Web Map Examples

You can view the interactive map examples directly in your browser via GitHub Pages or inspect their source code locally:

Example Description Source Code Live Demo
Leaflet Map Displays BGS sensor locations using Leaflet and the STAM (SensorThings API Map) plugin. web-maps/leaflet.html View Online
OpenLayers Map Displays BGS sensor locations using OpenLayers and the STAM plugin. web-maps/openlayers.html View Online
Federated Data Map Created as part of the NERC EDS Amplify project. Combines live data from multiple SensorThings API endpoints (BGS Sensors and LinkedSystems) with marker clustering, location search, box zoom, and interactive Plotly time-series charts. web-maps/federated.html View Online

Local HTML Development & Previewing

The files in web-maps/ are standalone HTML pages with no build step required. When editing them locally, serving them over a local HTTP server is recommended to avoid browser file:// CORS restrictions and to match how GitHub Pages serves the files:

Option 1: Python Built-in HTTP Server

Run the following command from the repository root:

python -m http.server 8000

Then open any of the maps in your browser (refreshing the page after saving changes):

Option 2: VS Code Live Server (Auto-Reload)

  1. Install the Live Server (or Live Preview) extension in VS Code.
  2. Right-click web-maps/federated.html in the Explorer panel and select Open with Live Server.
  3. The page will open in your browser and automatically reload whenever you save edits to the HTML, CSS, or JavaScript.

Running the Jupyter Notebook

You can view the notebook and its outputs directly on GitHub, open a mobile-friendly version on Jupyter nbviewer, or run it locally on your machine.

Prerequisites

Installation

  1. Clone this repository:

    git clone https://github.com/BritishGeologicalSurvey/sensor-things-api-demo.git
    cd sensor-things-api-demo
    
  2. (Optional) Create and activate a virtual environment:

    python3 -m venv .venv
    # On Linux/macOS:
    source .venv/bin/activate
    # On Windows (PowerShell):
    .venv\Scripts\Activate.ps1
    
  3. Install the required dependencies:

    pip3 install -r requirements.txt
    

Starting the Notebook

Launch Jupyter Notebook from the repository root:

jupyter notebook

A browser window will open at http://localhost:8888, where you can open sensor-things-api-demo.ipynb.


Testing (For Developers)

To verify that the notebook executes from start to finish without errors, install the development dependencies and run pytest with nbval:

pip3 install -r requirements.txt -r requirements_dev.txt
pytest --nbval-lax sensor-things-api-demo.ipynb

License

This project is released under the MIT License. Copyright (c) British Geological Survey.