Skip to main content

geoai2analytics-sdk icon

geoai2analytics-sdk

PyPI version Python versions pipeline status License: MIT DOI Downloads

Spatial statistics and GeoAI for Python analysts who want a single NumPy-only install: Moran's I, LISA and Getis–Ord hot spots, GWR/MGWR and spatial regression with inference checked against PySAL, plus SHAP explanations and conformal intervals for spatial models.

Three maps of one synthetic 24 by 24 lattice computed with geoai2analytics: Local Moran's I clusters with High-High cells in the north-east and Low-Low cells in the south-west, Getis-Ord Gi* z-scores from blue cold spots to red hot spots, and GWR local slopes rising from west to east.

Real output of local_moran, local_getis_ord_gi_star and GWR (script: docs/assets/make_assets.py).

Why geoai2analytics-sdk?

  • One dependency. NumPy is the only runtime requirement: no GDAL, SciPy, compiled extensions or system libraries, on Python 3.9 to 3.13.
  • Inference you can defend. LISA uses conditional permutations with folded pseudo p-values, Moran's I and Geary's C use the Cliff–Ord randomisation variances, and local maps can be corrected with Benjamini–Hochberg FDR. The test suite pins Geary's C, General G, Lee's L, GWR (AICc, local standard errors) and the four LM tests to reference values from PySAL esda, mgwr and spreg.
  • Fast GWR. Local regressions are solved in batches: the AICc bandwidth search plus the fit for 1,000 units takes 0.46 s on a laptop (see Performance below).
  • Formulas on the page. The manual states the equation behind each method (Moran, LISA, Gi*, Geary, FDR, GWR, SAR/SEM, LM tests, Huff, Wilson, conformal intervals) with its sources, next to an API reference generated from the code.
  • Tested and typed. 102 tests with 95 % line and branch coverage (measured with pytest-cov), a py.typed marker and 82 typed result dataclasses.

Installation

pip install geoai2analytics-sdk
Extra Adds Use it for
geo SciPy, Shapely, GeoPandas, scikit-learn GeoDataFrame workflows around the core (the core never imports them)
dev pytest, pytest-cov, ruff, mypy, build, twine running the tests and building the package

Python 3.9 to 3.13 (CI runs 3.9, 3.11 and 3.13). The import name is geoai2analytics.

Quickstart

import numpy as np
import geoai2analytics as geoai

data, w = geoai.generate_synthetic_spatial_dataset(n=120)  # bundled demo data, k-NN weights

moran = geoai.global_moran(data["y"], w, permutations=999)
print(f"Moran's I = {moran.I:.3f}  z = {moran.z_score:.2f}  pseudo p = {moran.p_sim:.3f}")

lisa = geoai.local_moran(data["y"], w, permutations=999, p_adjust="fdr_bh")
print(f"LISA after FDR: {lisa.high_high_count} High-High, {lisa.low_low_count} Low-Low units")

gi = geoai.local_getis_ord_gi_star(data["y"], w)
print(f"Getis-Ord Gi* hot spots at 95 %: {gi.hotspot_count_95}")

coords = np.column_stack([data["x_coord"], data["y_coord"]])
X = np.column_stack([data["X1"], data["X2"]])
gwr = geoai.GWR(coords, data["y"], X, kernel="bisquare", adaptive=True).fit()
print(f"GWR: {gwr.bandwidth:.0f} neighbours, AICc = {gwr.aicc:.1f}, R2 = {gwr.global_r2:.3f}")
Moran's I = 0.348  z = 7.32  pseudo p = 0.001
LISA after FDR: 8 High-High, 1 Low-Low units
Getis-Ord Gi* hot spots at 95 %: 11
GWR: 19 neighbours, AICc = 763.0, R2 = 0.980

Your own data only needs coordinates and values as NumPy arrays (for example from gdf.geometry.x and gdf.geometry.y); build the weights with knn_weights, distance_band_weights or grid_weights.

Features

  • Spatial weights: knn_weights, distance_band_weights (binary, Gaussian, bisquare and exponential kernels), grid_weights (rook or queen), row_standardize.
  • Autocorrelation and hot spots: global_moran, local_moran, local_getis_ord_gi_star, general_g, geary_c, local_geary, bivariate_moran, global_lee_l, join_count, colocation_quotient, geodetector_q, incremental_autocorrelation, spatial_gini, and adjust_p_values (Benjamini–Hochberg, Holm, Bonferroni).
  • Local and spatial regression: GWR, MGWR, fit_gw_poisson_regression, fit_spatial_lag (two-stage least squares), fit_spatial_error, fit_spatial_durbin, fit_spatial_regime (Chow test), eigenvector_spatial_filtering and lagrange_multiplier_diagnostics (LM and robust LM tests).
  • Point patterns and centrography: average_nearest_neighbor (Clark–Evans), ripleys_k, calculate_ripleys_k_bivariate, estimate_inhomogeneous_intensity, network_kernel_density_estimation, mean_center, standard_distance, standard_deviational_ellipse.
  • Clustering and anomalies: skater, spatial_dbscan, cluster_spatial_hdbscan, spatial_gmm, detect_spatial_density_anomalies.
  • Machine learning, explanations and uncertainty: SpatialRandomForestRegressor, ExplainableBoostingRegressor, SpatialCrossValidator, SpatialSHAP (Kernel SHAP), permutation_feature_importance, partial_dependence, ConformalPredictor and calibrate_spatial_conformal.
  • Space-time, interaction and simulation: SpaceTimeCube, mann_kendall_test, emerging_hotspot_analysis, spatiotemporal_poisson_scan_statistic, interpolate_spatiotemporal_kriging, huff_model, wilson_spatial_interaction, compute_gravity_accessibility_matrix, spatial_difference_in_differences, SpatialSEIRSimulator, simulate_urban_growth_ca.

Results come back as typed dataclasses of NumPy arrays and plain numbers.

Command line

geoai2analytics (or python -m geoai2analytics) prints version information, writes a synthetic dataset and runs Moran's I on it:

usage: geoai2analytics [-h] [-v] {info,synthetic,test-moran} ...

Pure-Python Spatial Statistics, Econometrics, and Explainable GeoAI Engine.

positional arguments:
  {info,synthetic,test-moran}
                        Available subcommands
    info                Display system and library capabilities
    synthetic           Generate synthetic spatial dataset with
                        autocorrelation
    test-moran          Run Global & Local Moran's I on synthetic dataset

options:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit

Performance

Measured on 2026-11-26 with benchmarks/run_benchmarks.py (fixed seeds, median of the listed repeats) on an AMD Ryzen 5 4600H laptop with other jobs running, Windows 11, Python 3.12.10, NumPy 2.5.5, geoai2analytics 0.13.3. Treat the figures as indicative: they depend on the CPU, the BLAS library and machine load.

Operation Size Median time Repeats
k-NN weights (k = 8, dense matrix) N = 5,000 2.99 s 3
Global Moran's I (999 permutations) N = 5,000 13.20 s 3
Local Moran's I / LISA (999 permutations, FDR) N = 5,000 1.25 s 3
Getis-Ord Gi* hot spots N = 5,000 439.4 ms 5
GWR: adaptive bandwidth search (AICc) + fit N = 1,000, p = 4 (with intercept) 464.9 ms 1
Random forest fit (25 trees, depth 6) N = 1,000, K = 4 2.34 s 1
Kernel SHAP values for every instance (100 coalitions, 50 background rows) N = 1,000, K = 4 27.51 s 1

Spatial weights are dense N-by-N matrices (about 200 MB at N = 5,000), so memory and the cost of each spatial lag grow with the square of N: the library suits city- and region-sized data of up to a few thousand units.

Documentation

API What it does
knn_weights, distance_band_weights Build a SpatialWeights matrix from coordinates
global_moran Moran's I with analytical and permutation p-values
local_moran LISA clusters and outliers, optional FDR correction
local_getis_ord_gi_star Hot and cold spots at the 90, 95 and 99 % levels
geary_c, general_g Global dissimilarity and high/low clustering tests
GWR, MGWR Local coefficients with AICc bandwidth selection
fit_spatial_lag, fit_spatial_error Spatial lag and spatial error models
lagrange_multiplier_diagnostics LM tests that choose between lag and error models
SpatialSHAP, ConformalPredictor Feature attributions and prediction intervals
huff_model, compute_gravity_accessibility_matrix Market shares and gravity accessibility
  • spatialcv: spatial block, buffered and NNDM cross-validation splitters (scikit-learn API) that yield train and test indices, so you can score geoai2analytics models without spatial leakage.
  • arealinterp: moves counts and rates from census tracts to your analysis zones as NumPy arrays, ready for global_moran or local_moran.
  • segstats: segregation and diversity indices for the group counts whose shares you map with LISA or Gi*.
  • retailgravity: calibrated Huff and MCI models with trade areas, when the fixed-exponent huff_model here is not enough.

Citation

If you use geoai2analytics-sdk in research, please cite the archived release (DOI 10.5281/zenodo.23677244; metadata in CITATION.cff):

@software{eminoglu2026geoai2analytics,
  author    = {Emino{\u{g}}lu, Yusuf},
  title     = {{geoai2analytics-sdk: Pure-Python Spatial Statistics, Econometrics, and Explainable GeoAI Engine}},
  year      = {2026},
  publisher = {Zenodo},
  version   = {0.13.3},
  doi       = {10.5281/zenodo.23677244},
  url       = {https://gitlab.com/geophilo1/geoai2analytics-sdk}
}

License

MIT. See LICENSE.

Metadata

Release files for geoai2analytics-sdk 0.13.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geoai2analytics-sdk 0.13.4
File Size Uploaded Provenance Actions
geoai2analytics_sdk-0.13.4.tar.gz 103.8 kB With provenance Details for geoai2analytics_sdk-0.13.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for geoai2analytics-sdk 0.13.4
File Interpreter ABI Platform Actions
geoai2analytics_sdk-0.13.4-py3-none-any.whl Python 3 none any Details for geoai2analytics_sdk-0.13.4-py3-none-any.whl

Total release size: 195.9 kB

Release files / geoai2analytics_sdk-0.13.4.tar.gz

Download URL geoai2analytics_sdk-0.13.4.tar.gz
Size 103.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fd0c1f91452af0811d7a5b186b5e4ae1bda0db5b15d2642eec56d09d27a91a38
BLAKE2b-256 checksum
How to use checksums
bddf8e4cd3837e1d2ff3124eb1274acf58550935981797938bff6e7f154e1154
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.18

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / geoai2analytics_sdk-0.13.4-py3-none-any.whl

Download URL geoai2analytics_sdk-0.13.4-py3-none-any.whl
Size 92.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd6eb41feb44ff0d71290a18ce403313b1ac2d010abaef729430f0cf23b3c0f9
BLAKE2b-256 checksum
How to use checksums
b2badd9f623acfeaf708e15d68e74e9559d197341661ed1889bcce4c472416bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.18

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Dec 1, 2026.

Transparency log

Security for geoai2analytics-sdk 0.13.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for geoai2analytics_sdk-0.13.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page