calculate_geodetic_distance
Measure the geodetic distance between two geographic points on Earth using WGS84 ellipsoid or a specified model. Ideal for precise geospatial analysis in GIS workflows.
Instructions
Calculate geodetic distance between points.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ellps | No | WGS84 | |
| point1 | Yes | ||
| point2 | Yes |
Implementation Reference
- src/gis_mcp/pyproj_functions.py:156-176 (handler)The handler function for the 'calculate_geodetic_distance' tool. It uses pyproj.Geod to compute the inverse geodetic problem, returning distance and azimuths between two lat/lon points.@gis_mcp.tool() def calculate_geodetic_distance(point1: List[float], point2: List[float], ellps: str = "WGS84") -> Dict[str, Any]: """Calculate geodetic distance between points.""" try: import pyproj geod = pyproj.Geod(ellps=ellps) lon1, lat1 = point1 lon2, lat2 = point2 forward_azimuth, back_azimuth, distance = geod.inv(lon1, lat1, lon2, lat2) return { "status": "success", "distance": distance, "forward_azimuth": forward_azimuth, "back_azimuth": back_azimuth, "ellps": ellps, "message": "Geodetic distance calculated successfully" } except Exception as e: logger.error(f"Error calculating geodetic distance: {str(e)}") raise ValueError(f"Failed to calculate geodetic distance: {str(e)}")
- src/gis_mcp/pyproj_functions.py:32-42 (registration)Resource listing 'calculate_geodetic_distance' among geodetic operations, aiding in tool discovery.@gis_mcp.resource("gis://crs/geodetic") def get_geodetic_operations() -> Dict[str, List[str]]: """List available geodetic operations.""" return { "operations": [ "get_geod_info", "calculate_geodetic_distance", "calculate_geodetic_point", "calculate_geodetic_area" ] }