Skip to main content

A graph-based framework for geotechnical site representation and subsurface intelligence

Project description

TerranGraph: A Graph-Based Framework for Geotechnical Site Representation

TerranGraph banner

TerranGraph — A unified graph learning framework for subsurface intelligence.

PyPI version   Python version   License: MIT

TerranGraph is a Python framework for geotechnical site representation, learning, and visualization. It integrates multi-source data processing, spatial graph construction, graph neural networks, and 3D visualization into a single workflow for subsurface modeling and prediction.


Overview

TerranGraph follows an end-to-end workflow:

Geotechnical Data → Spatial Graph → Representation Learning → Prediction → Visualization

Designed for subsurface modeling and site characterization, TerranGraph bridges geotechnical data and graph-based intelligence.


Features

  • Multi-source data integration for Excel and CSV geotechnical datasets
  • Spatial graph construction from borehole logs and spatial coordinates
  • Graph neural networks for site representation learning and prediction
  • 3D visualization with PyVista for subsurface modeling and cross-section analysis
  • Interactive GUI based on PyQt5 for workflow exploration
  • Scalable training with PyTorch and optional GPU acceleration
  • Model export to standard 3D formats such as PLY, OBJ, and STL

Installation

Install the lightweight core package:

pip install terrangraph

Install with graph learning support:

pip install terrangraph[ml]

Install with visualization support:

pip install terrangraph[viz]

Install full features:

pip install terrangraph[all]

Quick Start

from terrangraph import DataHandler, GeoModel, GeoVisualizer

# Load geotechnical data
handler = DataHandler()
unique_types, num_classes = handler.load_data("your_dataset.xlsx")

# Preprocess and align coordinates
rect = handler.compute_mbr()
bounds = handler.align_coordinates(x_res=10, y_res=2, z_res=1)
params_dict = handler.create_param_dict()

# Construct spatial graph
coords, labels, edges = handler.generate_grid(bounds, r=2)

# Train graph neural network
model = GeoModel()
model.prepare_data(coords, labels, edges)
model.build_model(
    num_classes=num_classes,
    hidden_size=48,
    gcn_layers=3,
    mlp_layers=3,
    dropout=0.2
)
history = model.train(epochs=100, lr=3e-3)

# Prediction and visualization
predictions, probabilities = model.predict()
visualizer = GeoVisualizer()
mesh = visualizer.create_model(coords, predictions)
visualizer.show_model(mesh)

Input Data Format

The input dataset should include:

  • X, Y, Z: spatial coordinates
  • Soil/Rock Type: soil or rock type classification
  • Borehole ID: borehole identifier (optional)
  • Borehole Type: borehole category (optional)

Additional geotechnical parameters (e.g., strength, density, CPT measurements, etc.) can be incorporated for extended modeling tasks.

Use Cases

TerranGraph can be used for:

  • 3D subsurface modeling
  • Borehole-based site characterization
  • Graph-based representation learning of geotechnical data
  • Similarity-based site comparison and clustering
  • Data-driven prediction of soil and rock properties

Project Structure

terrangraph/
├── src/
│   └── terrangraph/
│       ├── __init__.py              # Package exports
│       ├── cli.py                   # Command-line interface
│       └── core/
│           ├── __init__.py
│           ├── data_handler.py      # Data loading and preprocessing
│           ├── geo_model.py         # Graph neural network models
│           └── visualizer.py        # 3D visualization (PyVista)
│
├── assets/                          # Logo and banner images
├── docs/                            # Documentation files
├── CHANGELOG.md                     # Version history
├── LICENSE                          # License
├── pyproject.toml                   # Package configuration
└── README.md                        # Project documentation

Examples

See the examples/ directory:

  • basic_usage.py: basic workflow
  • advanced_visualization.py: advanced visualization
  • batch_processing.py: batch processing
  • custom_model.py: custom GNN architectures

Documentation

System Requirements

  • Python 3.8+
  • 8GB RAM minimum (16GB recommended)
  • CUDA-compatible GPU (required for ml)
  • OpenGL support for 3D visualization (required for viz)

Roadmap

Current Capabilities

  • Graph-based geotechnical site representation
  • Spatial graph construction from borehole data
  • GNN-based prediction framework
  • 3D subsurface visualization (PyVista)

Next Steps

  • Integration of additional geotechnical parameters (e.g., CPT, strength, density)
  • Integration of real-time monitoring data (e.g., tunneling operation data)
  • Contrastive learning for site similarity analysis
  • Support for large-scale geotechnical datasets
  • Probabilistic modeling and uncertainty quantification

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use TerranGraph in your research, please cite:

@software{wang2026terrangraph,
  author = {Wang, Lai},
  title = {TerranGraph: A Graph-Based Framework for Geotechnical Site Representation},
  year = {2026},
  version = {0.1.0},
  url = {https://github.com/wanglai25/terrangraph}
}

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terrangraph-0.1.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terrangraph-0.1.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file terrangraph-0.1.0.tar.gz.

File metadata

  • Download URL: terrangraph-0.1.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for terrangraph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6a0a3393bfd70f02b8375c79a586d3346b2c2fb51c23ec9e223ef5d1f9a7001d
MD5 a64951dd1aefcda5b7c61660051a13c6
BLAKE2b-256 5bb8be018551e691397a504018cec27d605b046960f00406d22fa913facec152

See more details on using hashes here.

File details

Details for the file terrangraph-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: terrangraph-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for terrangraph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 285a7a1661c2c3e464d09db2e86506c0cce17e6db88d1e6ecc189ea3b3f7e9ff
MD5 934ce0264b4a8aff17d67ae5313875e6
BLAKE2b-256 8bdc4cdea81d9a2c3930c309181d14cfa4694e07fff0a0fa43397039f5ef2735

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page