Documentation / @openassistant/geoda / thiessenPolygons
Variable: thiessenPolygons
constthiessenPolygons:OpenAssistantTool<ThiessenPolygonsArgs,ThiessenPolygonsLlmResult,ThiessenPolygonsAdditionalData,SpatialToolContext>
Defined in: src/spatial_ops/thiessenPolygons.ts:56
thiessenPolygons Tool
This tool creates Thiessen polygons (Voronoi diagrams) from a set of points. Thiessen polygons divide space into regions where each point is closer to its associated polygon than to any other point.
Thiessen Polygons
The tool creates Thiessen polygons with the following features:
- Voronoi Diagram: Divides space into regions based on proximity to input points
- Spatial Partitioning: Each polygon contains all locations closest to its associated point
- Network Analysis: Useful for service area analysis and spatial modeling
- Polygon Output: Returns the Thiessen polygons as polygon features for mapping
Parameters
datasetName: Name of the dataset with point geometries to create Thiessen polygons from (optional)geojson: GeoJSON string of point geometries to create Thiessen polygons from (optional)
Example user prompts:
- "Create Thiessen polygons from these points"
- "Generate Voronoi diagram for the facility locations"
- "Make service area polygons for these hospitals"
Example
typescript
import { thiessenPolygons } from "@openassistant/geoda";
import { convertToVercelAiTool } from "@openassistant/utils";
const thiessenTool = {
...thiessenPolygons,
context: {
getGeometries: async (datasetName: string) => {
// Implementation to retrieve geometries from your data source
return geometries;
},
},
};
const result = await generateText({
model: openai('gpt-4.1', { apiKey: key }),
prompt: 'Create Thiessen polygons from these points',
tools: { thiessenPolygons: convertToVercelAiTool(thiessenTool) },
});