Skip to main content
Glama

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
NameRequiredDescriptionDefault
geometryYes
toleranceYes
preserve_topologyNo

Implementation Reference

  • 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)}")
  • 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]:

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mahdin75/gis-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server