unary_union_geometries
Combine multiple geometries into a single unified shape for spatial analysis and data simplification in GIS workflows.
Instructions
Create a union of multiple geometries.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometries | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:388-403 (handler)The core handler function for the 'unary_union_geometries' tool. It takes a list of WKT geometry strings, computes their unary union using Shapely's unary_union, and returns the resulting geometry as WKT in a success dictionary.@gis_mcp.tool() def unary_union_geometries(geometries: List[str]) -> Dict[str, Any]: """Create a union of multiple geometries.""" try: from shapely import wkt from shapely.ops import unary_union geoms = [wkt.loads(g) for g in geometries] result = unary_union(geoms) return { "status": "success", "geometry": result.wkt, "message": "Union created successfully" } except Exception as e: logger.error(f"Error creating union: {str(e)}") raise ValueError(f"Failed to create union: {str(e)}")
- src/gis_mcp/shapely_functions.py:50-59 (registration)Registers 'unary_union_geometries' in the list of available advanced GIS operations accessible via the 'gis://operations/advanced' resource.@gis_mcp.resource("gis://operations/advanced") def get_advanced_operations() -> Dict[str, List[str]]: """List available advanced operations.""" return { "operations": [ "triangulate_geometry", "voronoi", "unary_union_geometries" ] }