Skip to content

Essay · July 8, 2026

What a natural-language query layer for PostGIS actually requires

The demo is easy and that's the problem. Point a language model at a PostGIS connection, let it write SQL, and within an afternoon you can ask "which parcels are within 500 meters of a school" and watch an answer appear. It feels like magic and it is roughly one storm away from telling a planner something confidently false. The distance between that demo and something an organization can rely on is where the actual engineering lives.

The model plans; it does not touch the database

The first requirement is a boundary the demo doesn't have: the language model never writes raw SQL against your data. It selects from a catalog of typed, audited spatial operations, each one a function with a known signature that a person wrote and tested. Ask for parcels near schools and the model chooses a within_distance operation and fills in the arguments. It cannot invent a table, cannot join two things that shouldn't be joined, and cannot quietly scan a column it was never meant to see.

This is slower to build and it is the whole point. A typed operation layer is what lets you hand the system to someone in a regulated organization and have them believe the answer.

Every answer carries its sources

The second requirement is provenance. An answer without its sources is a rumor. Every result the system returns names the features it came from: the parcel IDs, the layer, the date the data was last reconciled. If the system can't cite it, the system doesn't say it. That single rule kills most of the hallucination surface, because the model is no longer being asked to know things, only to route to operations that do.

Meaning lives next to geometry

The third requirement is that one database holds the geometry, the meaning, and the relationships together. Geometry in PostGIS, semantic search over the descriptions, and the graph of how features relate. When those live in three systems, the join becomes the bug. When they live in one, a question like "which of these easements touch a parcel that changed ownership this year" has somewhere to actually resolve.

The honest limit

Here's what we tell people before they hire us for this: the ceiling on quality is your data, not the model. If your layer names are inconsistent, your boundaries contradict each other, or nobody can say when a table was last true, a query layer will surface that faithfully and immediately. That's often the real value, and it's rarely what the buyer thought they were purchasing. We'd rather say it in the first conversation than discover it together in week three.