Skip to main content
Glama

geojson_to_geometry

Convert GeoJSON data to Shapely geometry and output as WKT format using the GIS MCP Server, enabling precise geospatial analysis and integration with AI-driven workflows.

Instructions

Convert GeoJSON to a Shapely geometry using shapely.shape. Args: geojson: GeoJSON dictionary. Returns: Dictionary with status, message, and geometry as WKT.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geojsonYes

Implementation Reference

  • The core handler function for the 'geojson_to_geometry' tool. It takes a GeoJSON dictionary, converts it to a Shapely geometry using shapely.shape(), and returns the result as WKT string in a success dict, or error dict on failure. Registered via @gis_mcp.tool() decorator.
    @gis_mcp.tool() def geojson_to_geometry(geojson: Dict[str, Any]) -> Dict[str, Any]: """ Convert GeoJSON to a Shapely geometry using shapely.shape. Args: geojson: GeoJSON dictionary. Returns: Dictionary with status, message, and geometry as WKT. """ try: from shapely import shape geom = shape(geojson) return { "status": "success", "geometry": geom.wkt, "message": "GeoJSON converted to geometry successfully" } except Exception as e: logger.error(f"Error in geojson_to_geometry: {str(e)}") return {"status": "error", "message": str(e)}
  • A resource handler that lists 'geojson_to_geometry' among Shapely utility operations, aiding discovery.
    @gis_mcp.resource("gis://operations/shapely_util") def get_shapely_util_operations() -> Dict[str, List[str]]: """List available Shapely utility/advanced operations.""" return { "operations": [ "snap_geometry", "nearest_point_on_geometry", "normalize_geometry", "geometry_to_geojson", "geojson_to_geometry" ] }

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