calculate_geodetic_area
Use geodetic calculations to determine the area of a polygon, accounting for Earth’s curvature. Ideal for precise geospatial analysis in GIS workflows.
Instructions
Calculate area of a polygon using geodetic calculations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ellps | No | WGS84 | |
| geometry | Yes |
Implementation Reference
- src/gis_mcp/pyproj_functions.py:198-216 (handler)The core handler function for the 'calculate_geodetic_area' tool. It takes a WKT geometry string and ellipsoid name (default WGS84), parses the polygon with shapely, computes the geodetic area using pyproj.Geod.geometry_area_perimeter, and returns the area in square meters along with status and message.@gis_mcp.tool() def calculate_geodetic_area(geometry: str, ellps: str = "WGS84") -> Dict[str, Any]: """Calculate area of a polygon using geodetic calculations.""" try: import pyproj from shapely import wkt geod = pyproj.Geod(ellps=ellps) polygon = wkt.loads(geometry) area = abs(geod.geometry_area_perimeter(polygon)[0]) return { "status": "success", "area": float(area), "ellps": ellps, "message": "Geodetic area calculated successfully" } except Exception as e: logger.error(f"Error calculating geodetic area: {str(e)}") raise ValueError(f"Failed to calculate geodetic area: {str(e)}")
- GIS MCP resource 'gis://crs/geodetic' that lists 'calculate_geodetic_area' as one of the available geodetic operations, providing tool discovery and implicit schema information.@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" ] }