convex_hull
Calculate the convex hull of a geometry to determine the smallest convex polygon that contains all points, useful for spatial analysis and boundary definition 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 handler function that implements the 'convex_hull' tool logic. It parses WKT input, computes the convex hull using Shapely.geometry.convex_hull, 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)}")
- src/gis_mcp/shapely_functions.py:24-37 (registration)Resource listing that includes 'convex_hull' as an available geometric operation, aiding in tool discovery.@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" ] }