Skip to content

Documentation v1.0.0


Documentation / @openassistant/geoda / dissolve

Variable: dissolve

const dissolve: OpenAssistantTool<DissolveFunctionArgs, DissolveLlmResult, DissolveAdditionalData, SpatialToolContext>

Defined in: src/spatial_ops/dissolve.ts:91

dissolve Tool

This tool merges multiple geometries into a single geometry by dissolving boundaries. It's useful for aggregating smaller administrative units into larger regions or creating simplified boundaries.

Dissolve Operations

The tool supports various dissolve operations:

  • Complete Dissolve: Merges all geometries into a single geometry
  • Dissolve by Attribute: Groups geometries by a common attribute value
  • Aggregated Dissolve: Combines geometries and aggregates associated values

Parameters

  • datasetName: Name of the dataset with geometries to be dissolved (optional)
  • geojson: GeoJSON string of geometries to be dissolved (optional)
  • dissolveBy: Variable to dissolve by (optional, dissolves entire dataset if not provided)
  • aggregateVariables: Variables to aggregate during dissolve with their operators (optional)

Example user prompts:

  • "Can you merge these counties into a single region?"
  • "Dissolve the census tracts by state and sum the population"
  • "Combine all the polygons into one geometry"

Example

typescript
import { dissolve } from "@openassistant/geoda";
import { convertToVercelAiTool } from "@openassistant/utils";

const dissolveTool = {
  ...dissolve,
  context: {
    getGeometries: async (datasetName: string) => {
      // Implementation to retrieve geometries from your data source
      return geometries;
    },
    getValues: async (datasetName: string, variableName: string) => {
      // Implementation to retrieve values from your data source
      return [100, 200, 150, 300, 250];
    },
  },
};

const result = await generateText({
  model: openai('gpt-4.1', { apiKey: key }),
  prompt: 'Can you merge these counties into a single region?',
  tools: { dissolve: convertToVercelAiTool(dissolveTool) },
});

Released under the MIT License.