Skip to main content
Glama

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

Implementation Reference

  • 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)}
  • 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.

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