intersection
Calculate the overlapping area where two geographic shapes intersect to identify shared spatial regions.
Instructions
Find intersection of two geometries.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry1 | Yes | ||
| geometry2 | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:120-135 (handler)The core handler function for the 'intersection' MCP tool. It takes two WKT geometry strings, loads them with shapely.wkt.loads, computes their intersection, and returns the result as WKT in a standardized dict format.@gis_mcp.tool() def intersection(geometry1: str, geometry2: str) -> Dict[str, Any]: """Find intersection of two geometries.""" try: from shapely import wkt geom1 = wkt.loads(geometry1) geom2 = wkt.loads(geometry2) result = geom1.intersection(geom2) return { "status": "success", "geometry": result.wkt, "message": "Intersection created successfully" } except Exception as e: logger.error(f"Error creating intersection: {str(e)}") raise ValueError(f"Failed to create intersection: {str(e)}")
- src/gis_mcp/main.py:66-72 (registration)Import statements in main.py that load the shapely_functions module, triggering automatic registration of all @gis_mcp.tool()-decorated functions, including 'intersection', via the FastMCP decorator system.from . import ( geopandas_functions, shapely_functions, rasterio_functions, pyproj_functions, pysal_functions, )
- src/gis_mcp/mcp.py:5-5 (registration)Definition of the central FastMCP server instance 'gis_mcp' used by decorators (@gis_mcp.tool()) to register tools like 'intersection'.gis_mcp = FastMCP("GIS MCP")
- MCP resource handler that lists available basic Shapely operations, including 'intersection', for tool discovery.@gis_mcp.resource("gis://operations/basic") def get_basic_operations() -> Dict[str, List[str]]: """List available basic geometric operations.""" return { "operations": [ "buffer", "intersection", "union", "difference", "symmetric_difference" ] }