poiidx
poiidx is a Python library for efficient spatial indexing and querying of Points of Interest (POIs) using PostgreSQL and PostGIS. It enables you to quickly find nearby POIs, retrieve administrative boundaries, and explore geographic hierarchies based on OpenStreetMap data.
📚 Read the full documentation for detailed guides, tutorials, and API reference.
Table of Contents
Installation
pip install poiidx
Database Setup
Install PostgreSQL and PostGIS
Ubuntu/Debian:
sudo apt update
sudo apt install postgresql postgis
macOS:
brew install postgresql@16 postgis
brew services start postgresql@16
Arch Linux:
sudo pacman -S postgresql postgis
sudo -u postgres initdb -D /var/lib/postgres/data
sudo systemctl start postgresql
Create Database and User
# Create user
sudo -u postgres createuser -P poiidx_user
# Enter password when prompted
# Create database
sudo -u postgres createdb -O poiidx_user poiidx_db
# Enable PostGIS extension
sudo -u postgres psql -d poiidx_db -c "CREATE EXTENSION postgis;"
Usage
import poiidx
from shapely.geometry import Point
# Initialize the database connection
poiidx.init(
host='localhost',
database='poiidx_db',
user='poiidx_user',
password='your_secure_password',
port=5432
)
# Find nearest POIs to a point (e.g., Berlin)
berlin_point = Point(13.4050, 52.5200)
nearest_pois = poiidx.get_nearest_pois(
berlin_point,
max_distance=1000, # meters
limit=5
)
for poi in nearest_pois:
print(f"{poi['name']} - Region: {poi['region']}, Rank: {poi['rank']}")
# Get administrative hierarchy for a point
admin_hierarchy = poiidx.get_administrative_hierarchy(berlin_point)
for admin in admin_hierarchy:
print(f"Level {admin['admin_level']}: {admin['name']}")
# Get administrative hierarchy as a formatted string
admin_str = poiidx.get_administrative_hierarchy_string(berlin_point)
print(admin_str)
# Get administrative hierarchy in a specific language (e.g., French)
admin_str_fr = poiidx.get_administrative_hierarchy_string(berlin_point, lang='fr')
print(admin_str_fr)
# Close the connection when done
poiidx.close()
License
poiidx is distributed under the terms of the MIT license.
Data Sources & Attribution
This project uses data from the following sources:
OpenStreetMap (via Geofabrik)
POI and administrative boundary data is sourced from OpenStreetMap, distributed via Geofabrik.
© OpenStreetMap contributors. Data available under the Open Database License (ODbL).
Wikidata
When country information is not available in OpenStreetMap data, it is supplemented using Wikidata.
© Wikidata contributors. Data available under CC0 1.0 Universal (CC0 1.0) Public Domain Dedication.
Metadata
Release files for poiidx 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| poiidx-0.1.0.tar.gz | 63.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| poiidx-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 90.9 kB
Release files / poiidx-0.1.0.tar.gz
| Download URL | poiidx-0.1.0.tar.gz |
|---|---|
| Size | 63.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
905b4a0837052938c220215ebde3c60dcb2a7274f2e5c206df98c03c6bec03c7
|
|
BLAKE2b-256 checksum How to use checksums |
c0eb6a493e44d583aa995bb40249cf9fdfdbe6a2375bfc68c43f296240b6992f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logRelease files / poiidx-0.1.0-py3-none-any.whl
| Download URL | poiidx-0.1.0-py3-none-any.whl |
|---|---|
| Size | 27.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76576ca54464741d4569334db1b37d1e00991d1f698efd281f5123e1f81a471d
|
|
BLAKE2b-256 checksum How to use checksums |
8746f3eb1e4e3ca3f033574fc8ba36c6b7503a0317f42c4294aabb18980c402c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency log