translate_geometry
Shift geometries by specified offsets in X, Y, and Z dimensions to reposition or align spatial data within a GIS environment using the GIS MCP Server.
Instructions
Translate a geometry.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes | ||
| xoff | Yes | ||
| yoff | Yes | ||
| zoff | No |
Implementation Reference
- src/gis_mcp/shapely_functions.py:335-351 (handler)The core handler function for the 'translate_geometry' MCP tool. It parses WKT input geometry, applies translation using shapely.affinity.translate with xoff, yoff, zoff offsets, and returns the resulting WKT geometry wrapped in a success dict.@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 that lists available geometric transformation operations, including 'translate_geometry', accessible at gis://operations/transformations.@gis_mcp.resource("gis://operations/transformations") def get_transformations() -> Dict[str, List[str]]: """List available geometric transformations.""" return { "operations": [ "rotate_geometry", "scale_geometry", "translate_geometry" ] }
- src/gis_mcp/shapely_functions.py:335-335 (registration)The @gis_mcp.tool() decorator registers the translate_geometry function as an MCP tool.@gis_mcp.tool()