convex_hull
Calculate the convex hull of a given geometry to identify the smallest convex polygon that fully encloses its points. Use this tool to perform accurate geospatial analysis and simplify complex shapes in GIS applications.
Instructions
Calculate convex hull of a geometry.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:189-203 (handler)The main handler function for the 'convex_hull' MCP tool, decorated with @gis_mcp.tool(). It takes a WKT geometry string, computes its convex hull using Shapely, and returns the result as WKT.@gis_mcp.tool() def convex_hull(geometry: str) -> Dict[str, Any]: """Calculate convex hull of a geometry.""" try: from shapely import wkt geom = wkt.loads(geometry) result = geom.convex_hull return { "status": "success", "geometry": result.wkt, "message": "Convex hull created successfully" } except Exception as e: logger.error(f"Error creating convex hull: {str(e)}") raise ValueError(f"Failed to create convex hull: {str(e)}")
- Resource handler that lists 'convex_hull' as one of the available geometric property operations.@gis_mcp.resource("gis://operations/geometric") def get_geometric_properties() -> Dict[str, List[str]]: """List available geometric property operations.""" return { "operations": [ "convex_hull", "envelope", "minimum_rotated_rectangle", "get_centroid", "get_bounds", "get_coordinates", "get_geometry_type" ] }