Skip to main content
Glama

geometry_to_geojson

Convert WKT geometry strings into GeoJSON format using Shapely's mapping function. Simplifies geospatial data transformation for integration with web mapping tools and GIS workflows.

Instructions

Convert a Shapely geometry (WKT) to GeoJSON using shapely.geometry.mapping. Args: geometry: WKT string of the geometry. Returns: Dictionary with status, message, and GeoJSON representation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geometryYes

Implementation Reference

  • The main handler function for the 'geometry_to_geojson' tool, decorated with @gis_mcp.tool() for MCP registration. Converts WKT geometry to GeoJSON using Shapely's mapping.
    @gis_mcp.tool() def geometry_to_geojson(geometry: str) -> Dict[str, Any]: """ Convert a Shapely geometry (WKT) to GeoJSON using shapely.geometry.mapping. Args: geometry: WKT string of the geometry. Returns: Dictionary with status, message, and GeoJSON representation. """ try: from shapely import wkt from shapely.geometry import mapping geom = wkt.loads(geometry) geojson = mapping(geom) return { "status": "success", "geojson": geojson, "message": "Geometry converted to GeoJSON successfully" } except Exception as e: logger.error(f"Error in geometry_to_geojson: {str(e)}") return {"status": "error", "message": str(e)}
  • Resource handler listing 'geometry_to_geojson' among available Shapely utility operations.
    @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