buffer
Generate a buffer zone around a specified geometry to analyze spatial relationships. Define distance, resolution, join style, mitre limit, and single-sided options for precise geospatial calculations.
Instructions
Create a buffer around a geometry.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| distance | Yes | ||
| geometry | Yes | ||
| join_style | No | ||
| mitre_limit | No | ||
| resolution | No | ||
| single_sided | No |
Implementation Reference
- src/gis_mcp/shapely_functions.py:96-119 (handler)The handler function for the 'buffer' MCP tool. It takes a WKT geometry string and parameters to create a buffer using Shapely's buffer method and returns the buffered geometry as WKT.@gis_mcp.tool() def buffer(geometry: str, distance: float, resolution: int = 16, join_style: int = 1, mitre_limit: float = 5.0, single_sided: bool = False) -> Dict[str, Any]: """Create a buffer around a geometry.""" try: from shapely import wkt geom = wkt.loads(geometry) buffered = geom.buffer( distance=distance, resolution=resolution, join_style=join_style, mitre_limit=mitre_limit, single_sided=single_sided ) return { "status": "success", "geometry": buffered.wkt, "message": "Buffer created successfully" } except Exception as e: logger.error(f"Error creating buffer: {str(e)}") raise ValueError(f"Failed to create buffer: {str(e)}")
- src/gis_mcp/shapely_functions.py:11-22 (registration)Resource listing that includes 'buffer' as one of the basic geometric operations available.@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" ] }
- Function signature providing the input schema (type hints) and output type for the buffer tool.def buffer(geometry: str, distance: float, resolution: int = 16, join_style: int = 1, mitre_limit: float = 5.0, single_sided: bool = False) -> Dict[str, Any]: