Quick Start¶
Overview¶
pygwmodel is a Python binding for libgwmodel that provides clear, high-performance interfaces for geographically weighted (GW) models based on GeoPandas.
Currently implemented models:
Geographically Weighted Regression (GWR) —
GWRBasicMultiscale GWR (MGWR) —
GWRMultiscaleGeographically and Temporally Weighted Regression (GTWR) —
GTWRGW Average —
GWAverageGW Correlation —
GWCorrelation
All algorithms use a C++17 core, exposed to Python via nanobind, with support for OpenMP multi-threading and CUDA GPU acceleration.
Installation¶
System Dependencies¶
Install the required native libraries:
# Ubuntu/Debian
sudo apt install libarmadillo-dev libgsl-dev libopenblas-dev
# or via conda/mamba
conda install armadillo gsl openblas -c conda-forge
Python Installation¶
git clone https://github.com/GWmodel-Lab/pygwmodel.git
cd pygwmodel
git submodule update --init --recursive
pip install .
On Windows, you must use OpenBLAS to avoid segmentation faults:
$Env:CMAKE_ARGS="-DBLA_VENDOR=OpenBLAS"
pip install .
Or pass the setting directly to pip:
pip install . --config-settings=cmake.args=-DBLA_VENDOR=OpenBLAS
Development Guide¶
Editable Install¶
An editable install lets you edit Python code without reinstalling:
pip install nanobind scikit-build-core[pyproject]
pip install --no-build-isolation -ve .
Running Tests¶
# Run directly
python test/test_gwr_basic.py test/londonhp100.csv
python test/test_gwr_multiscale.py test/londonhp100.csv
# Enable OpenMP test cases
ENABLE_OPENMP=true python test/test_gwr_multiscale.py test/londonhp100.csv
# Via CTest
ctest
Building Documentation¶
pip install furo sphinx
sphinx-build -b html -D language=en doc doc/_build/en # English
sphinx-build -b html -D language=zh_CN doc doc/_build/zh_CN # Chinese
Project Structure¶
pygwmodel/
├── libgwmodel/ # C++ core algorithms (git submodule)
├── src/ # nanobind C++ bindings + Python API
│ ├── pygwmodel/ # Python wrapper layer
│ └── *.cpp # C++ binding source files
├── test/ # Integration tests
├── doc/ # Sphinx documentation
└── pyproject.toml # Build configuration