Skip to main content
Glama

translate_geometry

Move a geometry by specified offsets in X, Y, and optionally Z directions to reposition spatial features in GIS analysis.

Instructions

Translate a geometry.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geometryYes
xoffYes
yoffYes
zoffNo

Implementation Reference

  • The core handler function for the 'translate_geometry' MCP tool. It parses WKT input geometry, applies translation using shapely.affinity.translate with xoff, yoff, and optional zoff offsets, and returns the resulting WKT geometry in a success response dictionary. Errors are logged and raised.
    @gis_mcp.tool()
    def translate_geometry(geometry: str, xoff: float, yoff: float, 
                        zoff: float = 0.0) -> Dict[str, Any]:
        """Translate a geometry."""
        try:
            from shapely import wkt
            from shapely.affinity import translate
            geom = wkt.loads(geometry)
            result = translate(geom, xoff=xoff, yoff=yoff, zoff=zoff)
            return {
                "status": "success",
                "geometry": result.wkt,
                "message": "Geometry translated successfully"
            }
        except Exception as e:
            logger.error(f"Error translating geometry: {str(e)}")
            raise ValueError(f"Failed to translate geometry: {str(e)}")
  • Helper resource endpoint that lists available geometric transformation operations, including 'translate_geometry', for discovery purposes.
    def get_transformations() -> Dict[str, List[str]]:
        """List available geometric transformations."""
        return {
            "operations": [
                "rotate_geometry",
                "scale_geometry",
                "translate_geometry"
            ]
        }
  • The @gis_mcp.tool() decorator registers the translate_geometry function as an MCP tool, with schema inferred from type hints and docstring.
    @gis_mcp.tool()
    def translate_geometry(geometry: str, xoff: float, yoff: float, 
                        zoff: float = 0.0) -> Dict[str, Any]:
        """Translate a geometry."""
        try:
            from shapely import wkt
            from shapely.affinity import translate
            geom = wkt.loads(geometry)
            result = translate(geom, xoff=xoff, yoff=yoff, zoff=zoff)
            return {
                "status": "success",
                "geometry": result.wkt,
                "message": "Geometry translated successfully"
            }
        except Exception as e:
            logger.error(f"Error translating geometry: {str(e)}")
            raise ValueError(f"Failed to translate geometry: {str(e)}")

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