Developer walkthrough · GIS
Build an AI-Powered GIS App
Follow Roman as he gives a web map an AI assistant that can find parcels, buffer streams, measure areas and export maps, using the official OpenVerb GIS verbs and Turf.js.
Last reviewed
A question planners ask every week
Roman is building a web map for a county planning office: parcels, streams, roads and zoning, on a Leaflet map. The staff know exactly what they want to ask it:
- “Which parcels are within 200 meters of Oak Creek?”
- “What's their total area?”
- “Color them orange and export a PDF for Thursday's meeting.”
Today every one of those questions goes to the one GIS specialist in the building. Roman wants the map itself to answer them, with an assistant that can run real spatial operations, not just describe them.
Same pattern, new domain
This is the same architecture as the CRM walkthrough. Roman's coding agent helps him build; the map's assistant is a different agent that operates the app for planners, through a defined list of actions. (Why that distinction matters: Your coding agent is not your application agent.)
What changes is the vocabulary. A CRM's verbs are about contacts and email. A map's verbs are about layers, geometry and coordinate systems, and OpenVerb already has a standard set.
Install the GIS verbs
@openverb/gis is a standard library of 44 GIS verbs with schemas and types. It deliberately does not perform any GIS computation itself: it defines what can be done, and your app decides how, with Turf.js, PostGIS, QGIS or ArcGIS. Roman's map runs in the browser, so he uses Turf.js:
npm install openverb @openverb/gis @turf/turfimport { createExecutor } from 'openverb';
import { gisLibrary, getVerbNames } from '@openverb/gis';
const executor = createExecutor(gisLibrary);
console.log(gisLibrary.namespace, getVerbNames().length); // "openverb.gis" 44Pick the verbs
The library covers layers, features, geometry, spatial analysis, coordinate systems, rasters, mapping and geocoding. Roman doesn't expose all 44: the planners' questions need only these.
| Verb | Category | Used for |
|---|---|---|
| query_features | Features | Find Oak Creek, then the parcels near it |
| buffer_geometry | Geometry | The 200-meter zone around the creek |
| union_geometry | Geometry | Merge parcels before measuring |
| calculate_area | Geometry | Total area |
| style_layer | Mapping | Color the results |
| export_map | Mapping | PDF for the meeting |
| delete_layer | Layers | Cleanup (destructive, needs confirmation) |
Each verb has typed parameters. buffer_geometry, for example, requires a GeoJSON geometry, a distance and units of meters, feet or degrees, and the package can check an action before anything runs:
import { validateGISAction } from '@openverb/gis';
validateGISAction({
verb: 'buffer_geometry',
params: { geometry: { type: 'Point', coordinates: [-74.006, 40.7128] }, distance: 150, units: 'meters' },
});
// { valid: true }Write the executors
Roman hands the plumbing to his coding agent with a specific brief:
Add an AI map assistant to our Leaflet app using OpenVerb GIS.
1. Install openverb, @openverb/gis and @turf/turf.
2. Create an executor from gisLibrary and register handlers for:
query_features, buffer_geometry, union_geometry, calculate_area,
style_layer, add_layer_to_map, export_map and delete_layer.
Use Turf.js for geometry and our existing layer service for data.
3. Expose only those verbs to the model as tools (convert each verb's
params to JSON Schema).
4. Never run delete_layer or delete_feature without the user confirming
in the UI. Both verbs are flagged destructive and requires_confirmation.
5. Add a chat panel beside the map. When a verb returns geometry, draw it.
6. Write tests for the denied and missing-parameter cases.The heart of it is a handful of handlers. The first is the package's own Turf.js example; the others follow the same shape:
import * as turf from '@turf/turf';
// buffer_geometry: the package's own integration example, using Turf.js
executor.register('buffer_geometry', ({ geometry, distance, units }) => {
const turfUnits = units === 'feet' ? 'feet' : units === 'meters' ? 'meters' : 'degrees';
return {
verb: 'buffer_geometry',
status: 'success',
data: { geometry: turf.buffer(geometry, distance, { units: turfUnits }) },
};
});
// query_features: attribute filter plus an optional spatial filter
executor.register('query_features', async ({ layer, expression, spatial_filter }) => {
let features = await layers.features(layer, expression); // your data source
if (spatial_filter) features = features.filter((f) => turf.booleanIntersects(f, spatial_filter));
return { verb: 'query_features', status: 'success', data: { features } };
});
// union_geometry + calculate_area: merge parcels, then measure
executor.register('union_geometry', ({ geometries }) => ({
verb: 'union_geometry',
status: 'success',
data: { geometry: turf.union(turf.featureCollection(geometries)) },
}));
executor.register('calculate_area', ({ geometry }) => ({
verb: 'calculate_area',
status: 'success',
data: { area: turf.area(geometry) }, // square meters
}));If the model forgets a required parameter, the executor stops it before Turf ever runs. Asked to buffer without units, it returns { status: 'error', error_message: 'Missing required param: units' }, and the model can correct itself.
Protect the data
Reading and analyzing are harmless; deleting a layer is not. The GIS library already marks delete_layer and delete_feature as destructive and requires_confirmation, so the same confirmation gate from the main guide holds them until a planner clicks Confirm.
The county wants one more rule: only signed-in staff may export maps, since exports go into public meeting packets. That belongs in a policy, checked on the server before export_map runs. The governance guide shows how.
Try it
A planner opens the map before Thursday's meeting:
User
Which parcels are within 200 meters of Oak Creek?
Verb call
query_features { "layer": "streams", "expression": "name = 'Oak Creek'" }
Verb call
buffer_geometry { "geometry": {…}, "distance": 200, "units": "meters" }
Verb call
query_features { "layer": "parcels", "spatial_filter": {…buffer} }
Assistant
14 parcels touch the 200-meter zone around Oak Creek. They're highlighted on the map.
User
What's their total area?
Verb call
union_geometry { "geometries": [ …14 parcels ] }
Verb call
calculate_area { "geometry": {…} }
Assistant
About 38.6 hectares in total.
User
Color them orange, export a PDF, and remove the old flood layer.
Verb call
style_layer { "layer": "oak-creek-parcels", "style": { "fill": "#f97316" } }
Verb call
export_map { "map_or_layout": "main", "path": "oak-creek.pdf", "format": "pdf" }
Policy
delete_layer { "layer": "flood-2019" } needs_confirmation · Permanently removes a layer
Assistant
Done: styled and exported oak-creek.pdf. Removing flood-2019 is permanent. Delete it?
The figures here are illustrative. The shape is what matters: every answer is a chain of real, typed operations the planner can see on the map, and the only irreversible step waited for a person.
Same verbs, any GIS engine
Here is the part that surprises GIS developers. Nothing the model sees is tied to Turf.js. The verbs are the same whether the work runs in the browser, in a database or on a desktop:
| Where it runs | Executor for buffer_geometry |
|---|---|
| Web map (this walkthrough) | Turf.js |
| Desktop | PyQGIS (the package documents a QGIS example) or ArcPy |
| Database | PostGIS SQL |
Move Roman's planners from the web map to QGIS, and the assistant's prompt, tools and rules stay the same; only the handlers change. One vocabulary, many engines: the same separation the governance essay describes, applied to geography.
To see it running, try the OpenVerb GIS demo app (Leaflet, Turf.js and OpenAI), or start with the OpenVerb GIS overview.