Skip to main content
Glama

get_centroid

Calculate the centroid of a geometry using the GIS MCP Server for precise geospatial analysis, enabling accurate geometric operations in AI-driven workflows.

Instructions

Get the centroid of a geometry.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geometryYes

Implementation Reference

  • The get_centroid tool handler: decorated with @gis_mcp.tool(), takes WKT geometry string, computes centroid using Shapely.geometry.centroid, returns WKT of centroid or raises error.
    @gis_mcp.tool() def get_centroid(geometry: str) -> Dict[str, Any]: """Get the centroid of a geometry.""" try: from shapely import wkt geom = wkt.loads(geometry) result = geom.centroid return { "status": "success", "geometry": result.wkt, "message": "Centroid calculated successfully" } except Exception as e: logger.error(f"Error calculating centroid: {str(e)}") raise ValueError(f"Failed to calculate centroid: {str(e)}")
  • Helper resource listing geometric property operations available via MCP, including get_centroid.
    @gis_mcp.resource("gis://operations/geometric") def get_geometric_properties() -> Dict[str, List[str]]: """List available geometric property operations.""" return { "operations": [ "convex_hull", "envelope", "minimum_rotated_rectangle", "get_centroid", "get_bounds", "get_coordinates", "get_geometry_type" ] }
  • MCP tool registration decorator for get_centroid.
    @gis_mcp.tool()

Other Tools

Related Tools

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