normalize_geometry
Standardize geometry orientation and order for consistent geospatial analysis. Input a WKT geometry to receive a normalized version as output.
Instructions
Normalize the orientation/order of a geometry using shapely.normalize. Args: geometry: WKT string of the geometry. Returns: Dictionary with status, message, and normalized geometry as WKT.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:537-558 (handler)The core handler function for the 'normalize_geometry' tool. It takes a WKT geometry string, normalizes it using Shapely's normalize function, and returns the result as WKT in a status dictionary. Registered via the @gis_mcp.tool() decorator.@gis_mcp.tool() def normalize_geometry(geometry: str) -> Dict[str, Any]: """ Normalize the orientation/order of a geometry using shapely.normalize. Args: geometry: WKT string of the geometry. Returns: Dictionary with status, message, and normalized geometry as WKT. """ try: from shapely import wkt, normalize geom = wkt.loads(geometry) normalized = normalize(geom) return { "status": "success", "geometry": normalized.wkt, "message": "Geometry normalized successfully" } except Exception as e: logger.error(f"Error in normalize_geometry: {str(e)}") return {"status": "error", "message": str(e)}
- src/gis_mcp/shapely_functions.py:82-93 (registration)Resource handler that lists 'normalize_geometry' among the available Shapely utility operations, indicating its registration in the MCP toolset.@gis_mcp.resource("gis://operations/shapely_util") def get_shapely_util_operations() -> Dict[str, List[str]]: """List available Shapely utility/advanced operations.""" return { "operations": [ "snap_geometry", "nearest_point_on_geometry", "normalize_geometry", "geometry_to_geojson", "geojson_to_geometry" ] }
- Function signature and docstring defining the input schema (geometry: str) and output format (Dict with status, geometry WKT, message). Serves as the tool schema in this decorator-based MCP implementation.def normalize_geometry(geometry: str) -> Dict[str, Any]: """ Normalize the orientation/order of a geometry using shapely.normalize. Args: geometry: WKT string of the geometry. Returns: Dictionary with status, message, and normalized geometry as WKT.