Skip to main content

k-nearest neighbour contexts/neighbourhoods on gridded and hexagonal data: bespoke neighbourhoods, friction growth, distance decay, statistics and segregation measures

Project description

EquiPop (Python)

k-nearest neighbour contexts/neighbourhoods on gridded and hexagonal data: bespoke neighbourhoods, friction-aware growth, distance decay, neighbourhood statistics and segregation measures - for very large datasets.

EquiPop finds, for every populated location, the k nearest individuals (by cumulative population count, expanding over a uniform grid) and reports the composition of that individualised neighbourhood. The gridded design means one pre-computed distance ordering serves every origin, which is what makes millions of locations feasible.

The EquiPop family

This is the first Python implementation. Its relatives: the original C# EquiPop (three generations, two public releases; radial and Flow models, downloadable via Uppsala University) and an R version covering I/O and the basic k-NN parts. This Python version additionally carries friction growth, five decay models, exact neighbourhood statistics (mean/median/SD/SE/Gini/entropy), segregation indices, hexagonal grids, area aggregation and metadata logging.

Install

pip install equipop            # core
pip install equipop[geo,io,viz]  # shapefiles/rasters, Excel/SPSS, maps

Quick start

import pandas as pd
from equipop import build_cells, run_knn_stats

df = pd.read_csv("individuals.csv")        # one row per individual
cd = build_cells(df, e_col="X", n_col="Y",
                 binary_vars=["treated"], value_vars=["income"],
                 unit_size=100)
res = run_knn_stats(cd, k_values=[100, 400, 1600, 6400],
                    stats={"treated": ["ratio"],
                           "income": ["mean", "median", "gini"]})

For aggregated counts at national scale use the vectorised run_knn_counts; for friction-constrained growth run_knn_friction; for segregation profiles seg_profile; for policy-area reporting aggregate_output; for quick maps map_output. See MANUAL_TOPICS.md.

Repository: https://github.com/GeoJohnSwe/EquiPop

Citing

Please cite the software and the methods you use - see CITATION.cff. Core reference: Östh (2014), Introducing the EquiPop software, Uppsala University. Segregation measures: Östh, Clark & Malmberg (2015), Geographical Analysis 47(1). Decay parameters: Östh, Lyhagen & Reggiani (2016), EJTIR 16(2). Friction growth: Östh & Türk (2020), Handbook of Urban Segregation. Decay profiles in application: Türk, Östh, Kourtit & Nijkamp (2026), Journal of Urban Mobility 9.

License

MIT. Attribution through citation is warmly requested (see above).

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

equipop-1.7.0.tar.gz (67.3 kB view details)

Uploaded Source

Built Distribution

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

equipop-1.7.0-py3-none-any.whl (63.6 kB view details)

Uploaded Python 3

File details

Details for the file equipop-1.7.0.tar.gz.

File metadata

  • Download URL: equipop-1.7.0.tar.gz
  • Upload date:
  • Size: 67.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for equipop-1.7.0.tar.gz
Algorithm Hash digest
SHA256 7ed8d1d4dd632b11659c066d4fa801f2ba064f1305e5af8c1e8259659f279d05
MD5 a2854c5c74b9204676c31a0a70f70c70
BLAKE2b-256 73da031607f2a776de1e66322307d0aac67230bf2b49842b879b4dd39cda1699

See more details on using hashes here.

File details

Details for the file equipop-1.7.0-py3-none-any.whl.

File metadata

  • Download URL: equipop-1.7.0-py3-none-any.whl
  • Upload date:
  • Size: 63.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for equipop-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2142c7478de0adbcb6692ae5ad907253e9f438939a12e3afcd0a02a4e78c63f9
MD5 7ab990e29f76c5788768a52eaa823482
BLAKE2b-256 b51b2ca9ab7980c0b2265dfbd60077d98815e15cd5f4e8aad923b0d24b5a1d11

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