rotate_geometry
Rotate geometric shapes by specifying an angle and optional origin point to adjust spatial orientation for GIS analysis.
Instructions
Rotate a geometry.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes | ||
| angle | Yes | ||
| origin | No | center | |
| use_radians | No |
Implementation Reference
- src/gis_mcp/shapely_functions.py:299-316 (handler)The core handler function implementing the 'rotate_geometry' tool. It takes WKT geometry string, angle, optional origin and use_radians flag, loads the geometry with shapely.wkt, rotates it using shapely.affinity.rotate, and returns the result as WKT in a success dict or raises error.@gis_mcp.tool() def rotate_geometry(geometry: str, angle: float, origin: str = "center", use_radians: bool = False) -> Dict[str, Any]: """Rotate a geometry.""" try: from shapely import wkt from shapely.affinity import rotate geom = wkt.loads(geometry) result = rotate(geom, angle=angle, origin=origin, use_radians=use_radians) return { "status": "success", "geometry": result.wkt, "message": "Geometry rotated successfully" } except Exception as e: logger.error(f"Error rotating geometry: {str(e)}") raise ValueError(f"Failed to rotate geometry: {str(e)}")