Documentation / @openassistant/geoda / buffer
Variable: buffer
constbuffer:OpenAssistantTool<BufferFunctionArgs,BufferLlmResult,BufferAdditionalData,SpatialToolContext>
Defined in: src/spatial_ops/buffer.ts:89
buffer Tool
This tool creates buffer zones around geometries. It's useful for creating zones of influence, safety perimeters, or proximity analysis around spatial features.
Buffer Creation
The tool supports creating buffers around various geometry types:
- Points: Creates circular buffers around point locations
- Lines: Creates buffers along line features (e.g., roads, rivers)
- Polygons: Creates buffers around polygon boundaries
Parameters
datasetName: Name of the dataset with geometries to be buffered (optional)geojson: GeoJSON string of geometries to be buffered (optional)distance: Buffer distance in the specified unitdistanceUnit: Unit for buffer distance - 'KM' for kilometers or 'Mile' for milespointsPerCircle: Smoothness of the buffer (10 = rough, 20 = smooth)
Example user prompts:
- "Can you create a 5km buffer around these roads?"
- "Create a 1-mile buffer around the school locations"
- "Generate a 500-meter buffer around the city boundaries"
Example
typescript
import { buffer } from "@openassistant/geoda";
import { convertToVercelAiTool } from "@openassistant/utils";
const bufferTool = {
...buffer,
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: 'Can you create a 5km buffer around these roads?',
tools: { buffer: convertToVercelAiTool(bufferTool) },
});TIP
You can also use this tool with other tools, e.g. geocoding, so you don't need to provide the getGeometries function. The geometries from geocoding tool will be used as the input for this tool.
