project_geometry
Transform geographic coordinates between coordinate reference systems for accurate spatial analysis and mapping.
Instructions
Project a geometry between CRS.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes | ||
| source_crs | Yes | ||
| target_crs | Yes |
Implementation Reference
- src/gis_mcp/pyproj_functions.py:64-84 (handler)The handler function for the 'project_geometry' MCP tool. It takes a WKT geometry string and CRS identifiers, projects the geometry using pyproj Transformer and shapely.transform, and returns the projected WKT geometry.@gis_mcp.tool() def project_geometry(geometry: str, source_crs: str, target_crs: str) -> Dict[str, Any]: """Project a geometry between CRS.""" try: from shapely import wkt from shapely.ops import transform from pyproj import Transformer geom = wkt.loads(geometry) transformer = Transformer.from_crs(source_crs, target_crs, always_xy=True) projected = transform(transformer.transform, geom) return { "status": "success", "geometry": projected.wkt, "source_crs": source_crs, "target_crs": target_crs, "message": "Geometry projected successfully" } except Exception as e: logger.error(f"Error projecting geometry: {str(e)}") raise ValueError(f"Failed to project geometry: {str(e)}")
- src/gis_mcp/pyproj_functions.py:9-17 (registration)Resource listing that registers 'project_geometry' as an available CRS transformation operation under the 'gis://crs/transformations' resource.@gis_mcp.resource("gis://crs/transformations") def get_crs_transformations() -> Dict[str, List[str]]: """List available CRS transformation operations.""" return { "operations": [ "transform_coordinates", "project_geometry" ] }