difference
Calculate the difference between two geometric shapes to analyze spatial relationships and identify variations in GIS data using the GIS MCP Server.
Instructions
Find difference between geometries.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry1 | Yes | ||
| geometry2 | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:154-169 (handler)The main handler function for the MCP 'difference' tool. It takes two WKT geometry strings, computes their set difference using Shapely.geometry.difference, and returns the result as WKT with status and message.@gis_mcp.tool() def difference(geometry1: str, geometry2: str) -> Dict[str, Any]: """Find difference between geometries.""" try: from shapely import wkt geom1 = wkt.loads(geometry1) geom2 = wkt.loads(geometry2) result = geom1.difference(geom2) return { "status": "success", "geometry": result.wkt, "message": "Difference created successfully" } except Exception as e: logger.error(f"Error creating difference: {str(e)}") raise ValueError(f"Failed to create difference: {str(e)}")