simplify
Reduce the complexity of geometric shapes by removing unnecessary vertices while preserving essential spatial characteristics, enabling efficient geospatial analysis.
Instructions
Simplify a geometry.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes | ||
| preserve_topology | No | ||
| tolerance | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:468-483 (handler)The handler function implementing the 'simplify' tool. It parses WKT geometry, applies Shapely's simplify with given tolerance and topology preservation, returns simplified WKT or raises error.@gis_mcp.tool() def simplify(geometry: str, tolerance: float, preserve_topology: bool = True) -> Dict[str, Any]: """Simplify a geometry.""" try: from shapely import wkt geom = wkt.loads(geometry) result = geom.simplify(tolerance=tolerance, preserve_topology=preserve_topology) return { "status": "success", "geometry": result.wkt, "message": "Geometry simplified successfully" } except Exception as e: logger.error(f"Error simplifying geometry: {str(e)}") raise ValueError(f"Failed to simplify geometry: {str(e)}")