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
| Name | Required | Description | Default |
|---|---|---|---|
| geojson | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:582-601 (handler)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)}
- src/gis_mcp/shapely_functions.py:82-93 (registration)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" ] }