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

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

pip install terrangraph

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},
  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.4.0.tar.gz (17.4 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.4.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for terrangraph-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3e8592f50660d66eef537306e956ad54f21caa73ccac4bc271c05e761f86f7ff
MD5 ab35573961a4e368b7fdddb267b0208f
BLAKE2b-256 e616327783dba30db4cf2405d4985bfeee7ae1f882b97e96bda1918aafcad769

See more details on using hashes here.

File details

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

File metadata

  • Download URL: terrangraph-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3740722fee4b64bdbb9e16317f28d3aea988e079f08f9bca3bc9dad4c2a6cfb9
MD5 a2bf56bc9768d1f4cf04e9e0fc0e7ceb
BLAKE2b-256 ef0eddf303ff28650bc96dbb6d0eb170937e51999fb5b986de2b823215bc8c89

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