intersection
Determine the overlapping area of two geometries using the GIS MCP Server, enabling precise geospatial analysis for accurate intersection identification.
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 primary handler for the 'intersection' MCP tool. Computes the geometric intersection of two input geometries (provided as WKT strings) using Shapely's intersection method and returns the result as WKT in a standardized response dictionary.@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 the main entry point that load the shapely_functions module, triggering the @gis_mcp.tool() decorator execution which registers the 'intersection' tool with the FastMCP server.from . import ( geopandas_functions, shapely_functions, rasterio_functions, pyproj_functions, pysal_functions, )
- Resource endpoint listing 'intersection' as one of the available basic geometric operations, aiding 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" ] }
- src/gis_mcp/mcp.py:5-6 (registration)Initialization of the FastMCP server instance 'gis_mcp' used by decorators (@gis_mcp.tool() and @gis_mcp.resource()) to register tools and resources.gis_mcp = FastMCP("GIS MCP")