Pyinterpolate

Pyinterpolate: Spatial interpolation in Python for point measurements and aggregated datasets - Published in JOSS (2022)

https://github.com/DataverseLabs/pyinterpolate

Science Score: 59.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
    1 of 14 committers (7.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.8%) to scientific vocabulary

Keywords

kriging machine-learning poisson-kriging python semivariogram spatial-analysis spatial-interpolation

Keywords from Contributors

spatial-data climate graph-theory network-analysis transportation mesh hydrology routing networks networkx
Last synced: 6 months ago · JSON representation

Repository

Kriging | Poisson Kriging | Variogram Analysis

Basic Info
Statistics
  • Stars: 165
  • Watchers: 2
  • Forks: 27
  • Open Issues: 5
  • Releases: 15
Topics
kriging machine-learning poisson-kriging python semivariogram spatial-analysis spatial-interpolation
Created almost 8 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct

README.md

status License Documentation Status CodeFactor

Pyinterpolate

version 1.0.3

Logo

Important notice

The package was updated to version 1.0 in June 2025. There are breaking API changes, so please, refer to the CHANGELOG to know more about the changes. Right now, the package in version 1.0.0 is in the beta stage, which means that it is stable but be careful with the production use. There might be some minor bugs, and large swaths of code are not optimized yet. If you find any bugs, please report them in the issue tracker.

Introduction

Pyinterpolate is the Python library for spatial statistics. The package provides access to spatial statistics tools (variogram analysis, Kriging, Poisson Kriging, Indicator Kriging, Inverse Distance Weighting).

If youre:

  • GIS expert
  • Geologist
  • Social scientist

Then you might find this package useful. The core functionalities of Pyinterpolate are spatial interpolation and spatial prediction for point and block datasets.

Pyinterpolate performs:

  1. Ordinary Kriging and Simple Kriging - spatial interpolation from points
  2. Centroid-based Poisson Kriging of polygons - spatial interpolation from blocks and regions
  3. Area-to-area and Area-to-point Poisson Kriging of Polygons - spatial interpolation and data deconvolution from areas to points
  4. Indicator Kriging - kriging based on probabilities
  5. Universal Kriging - kriging with trend
  6. Inverse Distance Weighting - benchmarking spatial interpolation technique
  7. Semivariogram regularization and deconvolution - transforming variogram of areal data in regards to point support data
  8. Semivariogram modeling and analysis - is your data spatially correlated? How do neighbors influence each other?

How does it work?

The package has multiple spatial interpolation functions. The flow of analysis is usually the same for each method:

[1.] Load your dataset with GeoPandas or numpy.

```python import geopandas as gpd

pointdata = gpd.readfile('dem.gpkg') # x (lon), y (lat), value ```

[2.] Pass loaded data to pyinterpolate, calculate experimental variogram.

```python from pyinterpolate import ExperimentalVariogram

stepsize = 500 maxrange = 40000

experimentalvariogram = ExperimentalVariogram( ds=pointdata, stepsize=stepsize, maxrange=maxrange ) ```

[3.] Fit experimental semivariogram to theoretical model, it is equivalent of the fit() method known from machine learning packages.

```python from pyinterpolate import buildtheoreticalvariogram

sill = experimentalvariogram.variance nugget = 0 variogramrange = 8000

semivar = buildtheoreticalvariogram( experimentalvariogram=experimentalvariogram, modelsgroup='linear', nugget=nugget, rang=variogramrange, sill=sill ) ```

[4.] Interpolate values in unknown locations.

```python from pyinterpolate import ordinary_kriging

unknownpoint = (20000, 65000) prediction = ordinarykriging(theoreticalmodel=semivar, knownlocations=pointdata, unknownlocation=unknownpoint, noneighbors=32) ```

[5.] Analyze error and uncertainty of predictions.

python print(prediction) # [predicted, variance error, lon, lat]

```bash

[211.23, 0.89, 20000, 60000] ```

With Pyinterpolate you can analyze and transform aggregated data. Here is the example of spatial disaggregation of areal data into point support using Poisson Kriging:

Example use case

Status

Operational: no API changes in the current release cycle.

Setup

Setup with conda: conda install -c conda-forge pyinterpolate

Setup with pip: pip install pyinterpolate

Detailed instructions on how to install the package are presented in the file SETUP.md. We pointed out there most common problems related to third-party packages.

You may follow those setup steps to create a conda environment with the package for your work:

Recommended - conda installation

[1.] Create conda environment with Python >= 3.10

shell conda create -n [YOUR ENV NAME] -c conda-forge python=3.10 pyinterpolate

[2.] Activate environment.

conda activate [YOUR ENV NAME]

[3.] You are ready to use the package!

pip installation

With Python>=3.9 and system libspatialindex_c.so dependencies you may install package by simple command:

pip install pyinterpolate

A world of advice, you should always use Virtual Environment for the installation. You may consider using PipEnv too.

Tests and contribution

All tests are grouped in the test directory. If you would like to contribute, then you won't avoid testing, but it is described step-by-step here: CONTRIBUTION.md

Commercial and scientific projects where library has been used

  • Tick-Borne Disease Detector (Data Lions company) for the European Space Agency (2019-2020).
  • B2C project related to the prediction of demand for specific flu medications (2020).
  • B2G project related to the large-scale infrastructure maintenance (2020-2021).
  • E-commerce service for reporting and analysis, building spatial / temporal profiles of customers (2022+).
  • The external data augmentation for e-commerce services (2022+).
  • Regional aggregates transformation and preprocessing for location intelligence tasks (2025+).

Community

Join our community in Discord: Discord Server Pyinterpolate

Bibliography

Pyinterpolate was created thanks to many resources and all of them are pointed here:

  • Armstrong M., Basic Linear Geostatistics, Springer 1998,
  • GIS Algorithms by Ningchuan Xiao: https://uk.sagepub.com/en-gb/eur/gis-algorithms/book241284
  • Pardo-Iguzquiza E., VARFIT: a fortran-77 program for fitting variogram models by weighted least squares, Computers & Geosciences 25, 251-261, 1999,
  • Goovaerts P., Kriging and Semivariogram Deconvolution in the Presence of Irregular Geographical Units, Mathematical Geology 40(1), 101-128, 2008
  • Deutsch C.V., Correcting for Negative Weights in Ordinary Kriging, Computers & Geosciences Vol.22, No.7, pp. 765-773, 1996

How to cite

Moliski, S., (2022). Pyinterpolate: Spatial interpolation in Python for point measurements and aggregated datasets. Journal of Open Source Software, 7(70), 2869, https://doi.org/10.21105/joss.02869

Requirements and dependencies (v 1.x)

Core requirements and dependencies are:

  • Python >= 3.10
  • geopandas
  • matplotlib
  • numpy
  • prettytable
  • pydantic
  • scipy
  • tqdm

You may check a specific version of requirements in the setup.cfg file. Required packages versions are updated in a regular interval.

Package structure

High level overview:

  • [x] pyinterpolate
    • [x] core - data structures and models, data processing pipelines
    • [x] distance - distance and angles
    • [x] evaluate - cross-validation and modeling metrics
    • [x] idw - inverse distance weighting
    • [x] kriging - Ordinary Kriging, Simple Kriging, Poisson Kriging: centroid based, area-to-area, area-to-point, Indicator Kriging
    • [x] transform - internal data processing functions
    • [x] semivariogram - experimental variogram, theoretical variogram, variogram point cloud, semivariogram regularization & deconvolution, indicator variogram
    • [x] viz - interpolation of smooth surfaces from points into rasters.
  • [x] tutorials
    • [x] api-examples - tutorials covering the API
    • [x] functional - tutorials covering concrete use cases

Datasets

Datasets and scripts to download spatial data from external API's are available in a dedicated package: pyinterpolate-datasets

API documentation

https://pyinterpolate.readthedocs.io/en/latest/

Owner

  • Name: Dataverse Labs
  • Login: DataverseLabs
  • Kind: organization
  • Email: simon@dataverselabs.com

GitHub Events

Total
  • Create event: 15
  • Issues event: 9
  • Release event: 3
  • Watch event: 17
  • Delete event: 12
  • Issue comment event: 12
  • Push event: 155
  • Gollum event: 1
  • Pull request event: 45
Last Year
  • Create event: 15
  • Issues event: 9
  • Release event: 3
  • Watch event: 17
  • Delete event: 12
  • Issue comment event: 12
  • Push event: 155
  • Gollum event: 1
  • Pull request event: 45

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 674
  • Total Committers: 14
  • Avg Commits per committer: 48.143
  • Development Distribution Score (DDS): 0.401
Past Year
  • Commits: 15
  • Committers: 3
  • Avg Commits per committer: 5.0
  • Development Distribution Score (DDS): 0.133
Top Committers
Name Email Commits
Szymon s****n@m****m 404
szymon-datalions s****i@d****u 243
scottgallacher-3 6****3 4
Hugo Ledoux h****x@t****l 4
szymon s****s 4
Taher Chegini c****t@g****m 4
dependabot[bot] 4****] 3
Ethem e****t@g****m 2
Martin Fleischmann m****n@m****t 1
Lakshaya Inani l****i@g****m 1
seanjunheng2 s****g@g****m 1
TobiaszWojnar w****z@g****m 1
NarayanAdithya n****4@g****m 1
Szymon Moliński s****i@m****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 60
  • Total pull requests: 127
  • Average time to close issues: 3 months
  • Average time to close pull requests: about 2 hours
  • Total issue authors: 3
  • Total pull request authors: 5
  • Average comments per issue: 0.63
  • Average comments per pull request: 0.06
  • Merged pull requests: 118
  • Bot issues: 0
  • Bot pull requests: 10
Past Year
  • Issues: 8
  • Pull requests: 45
  • Average time to close issues: about 2 months
  • Average time to close pull requests: about 3 hours
  • Issue authors: 2
  • Pull request authors: 4
  • Average comments per issue: 0.25
  • Average comments per pull request: 0.0
  • Merged pull requests: 38
  • Bot issues: 0
  • Bot pull requests: 9
Top Authors
Issue Authors
  • SimonMolinsky (56)
  • martinfleis (5)
Pull Request Authors
  • SimonMolinsky (117)
  • dependabot[bot] (11)
  • martinfleis (2)
  • awurno (1)
  • cheginit (1)
Top Labels
Issue Labels
feature (26) math and logic (16) documentation (9) issue (8) bug (8) Good First Issue (7) dependencies (6) help needed (5) concept (4) NEW RELEASE (2)
Pull Request Labels
dependencies (11) python (9)

Packages

  • Total packages: 4
  • Total downloads:
    • pypi 406 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 2
    (may contain duplicates)
  • Total versions: 63
  • Total maintainers: 1
proxy.golang.org: github.com/DataverseLabs/pyinterpolate
  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
proxy.golang.org: github.com/dataverselabs/pyinterpolate
  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
pypi.org: pyinterpolate
  • Versions: 33
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 406 Last month
Rankings
Stargazers count: 6.3%
Forks count: 8.1%
Dependent packages count: 10.1%
Average: 11.8%
Downloads: 12.9%
Dependent repos count: 21.6%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: pyinterpolate
  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 1
Rankings
Dependent repos count: 24.4%
Stargazers count: 34.2%
Average: 37.1%
Forks count: 38.1%
Dependent packages count: 51.6%
Last synced: 6 months ago

Dependencies

.github/workflows/python-package-install-linux-check.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
.github/workflows/python-package-install-macos-check.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
.github/workflows/python-package-install-windows-check.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite