triangulate_geometry
Generate triangulated mesh from geometry for geospatial analysis, enabling precise modeling and spatial measurements in GIS operations via the MCP server.
Instructions
Create a triangulation of a geometry.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:354-370 (handler)The core handler function for the 'triangulate_geometry' tool. It parses WKT input, uses shapely.ops.triangulate to generate triangles, and returns their WKT representations.@gis_mcp.tool() def triangulate_geometry(geometry: str) -> Dict[str, Any]: """Create a triangulation of a geometry.""" try: from shapely import wkt from shapely.ops import triangulate geom = wkt.loads(geometry) triangles = triangulate(geom) return { "status": "success", "geometries": [tri.wkt for tri in triangles], "message": "Triangulation created successfully" } except Exception as e: logger.error(f"Error creating triangulation: {str(e)}") raise ValueError(f"Failed to create triangulation: {str(e)}")
- Helper resource that lists 'triangulate_geometry' among available advanced GIS operations.@gis_mcp.resource("gis://operations/advanced") def get_advanced_operations() -> Dict[str, List[str]]: """List available advanced operations.""" return { "operations": [ "triangulate_geometry", "voronoi", "unary_union_geometries" ] }