unary_union_geometries
Merge multiple geometries into a single unified shape using the GIS MCP Server, enabling efficient geospatial analysis and simplifying complex spatial datasets.
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 handler function for the 'unary_union_geometries' tool. It takes a list of WKT geometry strings, loads them using shapely.wkt.loads, computes the unary union using shapely.ops.unary_union, and returns the result as WKT in a success dict. Registered via @gis_mcp.tool() decorator.@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)Resource handler listing 'unary_union_geometries' among advanced operations available via gis://operations/advanced.@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" ] }