---
title: "Maps with PostgreSQL and PostGIS"
description: "PostGIS can generate Mapbox vector tiles directly, so a browser map needs only PostgreSQL/PostGIS, a thin tile server (pg_tileserv) and a Leaflet frontend, with no heavy tiling middleware."
url: "https://swe.quest/articles/maps-with-postgresql-and-postgis-b8b01c8d5b51a400"
canonical: "https://engineering.zalando.com/posts/2021/12/maps-with-postgresql-and-postgis.html"
source: "Zalando Engineering"
published: "2021-12-01"
difficulty: "medium"
kind: "How-to"
reading_minutes: 7
tags: ["geospatial","postgres","kubernetes","frontend"]
---

# Maps with PostgreSQL and PostGIS

A post on [Zalando Engineering](https://swe.quest/sources/zalando.md), published 2021-12-01, 7 min read, How-to. Original: [https://engineering.zalando.com/posts/2021/12/maps-with-postgresql-and-postgis.html](https://engineering.zalando.com/posts/2021/12/maps-with-postgresql-and-postgis.html)

## Summary

PostGIS can generate Mapbox vector tiles directly, so a browser map needs only PostgreSQL/PostGIS, a thin tile server (pg\_tileserv) and a Leaflet frontend, with no heavy tiling middleware. The stack runs on Kubernetes: Zalando's Postgres Operator provisions an HA cluster with the PostGIS extension, roles and schemas from a short manifest, and pg\_tileserv is deployed with a ConfigMap-mounted TOML config behind an OAuth proxy. Beyond serving tables, SQL function layers built on ST\_TileEnvelope, ST\_HexagonGrid and ST\_AsMVT can produce dynamic hexagon heatmaps (here joined against Geostat population data) whose resolution adapts to the zoom level.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Maps & geospatial](https://swe.quest/tags/geospatial.md) (Domains)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Kubernetes](https://swe.quest/tags/kubernetes.md) (Infrastructure)
- [Frontend](https://swe.quest/tags/frontend.md) (Web & mobile)

## Prerequisites

- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- Kubernetes manifests ([easy posts on Kubernetes](https://swe.quest/tags/kubernetes.md?difficulty=easy))
- basic SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

PostGIS, pg\_tileserv, Leaflet.js, Postgres Operator, ST\_AsMVT, OpenStreetMap, GDAL ogr2ogr, Spilo

## Related posts

- [Generate Vector Tiles with PostGIS](https://swe.quest/articles/generate-vector-tiles-with-postgis-b14acc8d0f59fc3b.md): Supabase · 2024-06-26 · Medium · 6 min read · Maps & geospatial, PostgreSQL, Frontend
  PostGIS can generate Mapbox Vector Tiles on demand from Postgres rows, so a MapLibre GL client can render large point datasets while transferring only the data for the current viewport and zoom level.
- [Geo Queries with PostGIS in Ionic Angular](https://swe.quest/articles/geo-queries-with-postgis-in-ionic-angular-9afa3d65d6fa3030.md): Supabase · 2023-03-01 · Medium · 20 min read · PostgreSQL, Maps & geospatial, Mobile, Frontend
  PostGIS on Supabase handles geo data for an Ionic Angular app with a Capacitor Google Map.
- [Postgres Realtime location sharing with MapLibre](https://swe.quest/articles/postgres-realtime-location-sharing-with-maplibre-f6d03ffa8efe5716.md): Supabase · 2024-07-04 · Medium · 5 min read · Real-time systems, Maps & geospatial, PostgreSQL, React, Serverless
  Live location sharing is built by having a Telegram bot running in a Supabase Edge Function (grammY on Deno) capture edited-location updates and write them to Postgres through a PL/pgSQL RPC.
- [Hosting Postgres with GeoLite2: a practical guide to IP geolocation, data loading, and updates](https://swe.quest/articles/hosting-postgres-with-geolite2-a-practical-guide-to-ip-geolocation-data-loading-f98c61ed175d32d1.md): Railway · 2025-12-16 · Medium · 8 min read · PostgreSQL, Maps & geospatial, Data pipelines
  Loading MaxMind's GeoLite2 CSVs into Postgres pays off over the MMDB binary format when you need SQL joins, batch geolocation of many IPs, queries over the ranges themselves, or one copy shared across services; for simple single-IP lookups MMDB is easier.
- [postgres.new: In-browser Postgres with an AI interface](https://swe.quest/articles/postgres-new-in-browser-postgres-with-an-ai-interface-55583d716a34d5b8.md): Supabase · 2024-08-12 · Medium · 11 min read · PostgreSQL, WebAssembly, LLMs, AI agents, Browsers
  database.build (formerly postgres.new) runs unlimited Postgres databases entirely in the browser via PGlite, a WASM build of Postgres, paired with GPT-4o that has full autonomy over the disposable database.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
