Production-grade spatial database engineering for backend developers, GIS admins, and platform teams.
A free, in-depth documentation site covering the full stack of building fast, reliable
spatial systems with PostGIS and Python — from bounding-box pre-filters and KNN
distance operators to GiST index architecture, ORM integration, live schema migrations,
and production performance monitoring. Every pattern pairs runnable PostGIS SQL with real
psycopg / SQLAlchemy 2.0 / GeoAlchemy2 / Shapely integration code — no pseudocode.
Spatial workloads rarely fail from a single missing index. They fail from misaligned index architecture, query-planner misestimates, and driver-level translation issues that only show up under load. These guides bridge the gap between PostGIS internals and Python application patterns, with EXPLAIN-plan walkthroughs, explicit SRID handling, and copy-paste-ready implementations validated against production-shaped workloads.
- Core Spatial Query Patterns — bounding-box filtering with the
&&operator,ST_DWithinradius searches, KNN<->nearest-neighbor queries, and spatial joins. - Advanced GiST Indexing & Optimization — partial and composite indexes, index-only scans,
EXPLAIN (ANALYZE, BUFFERS)interpretation, and choosing between GiST, SP-GiST, and BRIN. - SQLAlchemy & GeoAlchemy2 Integration — model mapping, session management, hybrid geometry properties, type coercion / serialization, driver selection, and async streaming.
- Spatial Schema Migrations & Evolution — adding geometry columns to live tables, in-place SRID reprojection, concurrent index builds, and zero-downtime backfills.
- Spatial Performance Monitoring & Observability —
pg_stat_statementsfor spatial hotspots, GiST index bloat detection, and autovacuum tuning for geometry-heavy tables.
- Eleventy static site generator (Nunjucks + Markdown)
- Hand-authored, theme-adaptive inline SVG diagrams
- Structured data (JSON-LD), accessible (WCAG 2 A/AA) markup, and a PWA service worker
- Deployed on Cloudflare Workers (Static Assets)
npm install
npm start # local dev server with live reload
npm run build # build to _site/
npm run deploy # build + deploy to Cloudflare WorkersSpotted an error, an outdated PostGIS/Python idiom, or a pattern worth adding? Issues and pull requests are welcome.
Content and code © the PostGIS + Python project. See the repository for details.