Skip to main content
Glama

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
NameRequiredDescriptionDefault
geometryYes
source_crsYes
target_crsYes

Implementation Reference

  • 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)}")
  • 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"
            ]
        }

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