transform_coordinates
Convert geographic coordinates between different coordinate reference systems (CRS) for accurate spatial data alignment and analysis.
Instructions
Transform coordinates between CRS.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coordinates | Yes | ||
| source_crs | Yes | ||
| target_crs | Yes |
Implementation Reference
- src/gis_mcp/pyproj_functions.py:44-62 (handler)The core handler function for the 'transform_coordinates' MCP tool. It takes a list of two floats (x,y), source CRS string, target CRS string, creates a pyproj Transformer, transforms the point, and returns a dict with the result.@gis_mcp.tool() def transform_coordinates(coordinates: List[float], source_crs: str, target_crs: str) -> Dict[str, Any]: """Transform coordinates between CRS.""" try: from pyproj import Transformer transformer = Transformer.from_crs(source_crs, target_crs, always_xy=True) x, y = coordinates x_transformed, y_transformed = transformer.transform(x, y) return { "status": "success", "coordinates": [x_transformed, y_transformed], "source_crs": source_crs, "target_crs": target_crs, "message": "Coordinates transformed successfully" } except Exception as e: logger.error(f"Error transforming coordinates: {str(e)}") raise ValueError(f"Failed to transform coordinates: {str(e)}")