Skip to main content
Glama

geojson_to_geometry

Convert GeoJSON data to Shapely geometry for geospatial analysis in GIS applications, returning geometry as WKT format.

Instructions

Convert GeoJSON to a Shapely geometry using shapely.geometry.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, decorated with @gis_mcp.tool(). It converts a GeoJSON dictionary to a Shapely geometry and returns it as WKT string.
    @gis_mcp.tool()
    def geojson_to_geometry(geojson: Dict[str, Any]) -> Dict[str, Any]:
        """
        Convert GeoJSON to a Shapely geometry using shapely.geometry.shape.
        Args:
            geojson: GeoJSON dictionary.
        Returns:
            Dictionary with status, message, and geometry as WKT.
        """
        try:
            from shapely.geometry 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)}
  • Resource listing that includes 'geojson_to_geometry' as one of the 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"
            ]
        }

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