calculate_geodetic_area
Calculate polygon area using geodetic methods for accurate geospatial analysis in GIS applications.
Instructions
Calculate area of a polygon using geodetic calculations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes | ||
| ellps | No | WGS84 |
Implementation Reference
- src/gis_mcp/pyproj_functions.py:222-240 (handler)Main handler function for the 'calculate_geodetic_area' tool. Parses WKT geometry, uses pyproj.Geod.geometry_area_perimeter to compute the geodetic area on the specified ellipsoid, and returns the result in square meters.@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, "unit": "square_meters", "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)}")
- src/gis_mcp/pyproj_functions.py:32-42 (registration)Resource listing that includes 'calculate_geodetic_area' as one of the available geodetic operations.@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" ] }