buffer
Create a buffer zone around geographic features to analyze proximity, define boundaries, or calculate spatial relationships in GIS workflows.
Instructions
Create a buffer around a geometry.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes | ||
| distance | Yes | ||
| resolution | No | ||
| join_style | No | ||
| mitre_limit | 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 WKT geometry string, distance, and buffer parameters, uses Shapely to create a buffer, and returns the resulting WKT geometry in a success dict or raises error.@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)}")
- Function signature providing input schema via type hints (geometry: str WKT, distance: float, etc.) and output as Dict[str, Any], with docstring description.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]:
- src/gis_mcp/shapely_functions.py:96-96 (registration)The @gis_mcp.tool() decorator registers this function as the MCP tool named 'buffer'.@gis_mcp.tool()