Skip to main content
Glama

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
NameRequiredDescriptionDefault
geometry1Yes
geometry2Yes

Implementation Reference

  • 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)}")
  • 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" ] }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mahdin75/gis-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server