simplify
Reduce geometric complexity while preserving essential shapes for GIS analysis. Specify tolerance to control simplification level and maintain topology as needed.
Instructions
Simplify a geometry.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes | ||
| tolerance | Yes | ||
| preserve_topology | No |
Implementation Reference
- src/gis_mcp/shapely_functions.py:468-483 (handler)The handler function for the 'simplify' tool. It takes a WKT geometry string and tolerance, simplifies the geometry using Shapely's simplify method, and returns the result as WKT.@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)}")
- src/gis_mcp/shapely_functions.py:71-80 (registration)Resource listing that includes 'simplify' as an available validation operation, aiding in tool discovery.@gis_mcp.resource("gis://operations/validation") def get_validation_operations() -> Dict[str, List[str]]: """List available validation operations.""" return { "operations": [ "is_valid", "make_valid", "simplify" ] }
- Function signature defining the input schema (geometry: str, tolerance: float, preserve_topology: bool=True) and output (Dict[str, Any]).def simplify(geometry: str, tolerance: float, preserve_topology: bool = True) -> Dict[str, Any]: