Skip to main content
Glama

dissolve_gpd

Simplify and merge geospatial features by specified attributes to reduce complexity in GIS datasets. Ideal for integrating overlapping geometries into unified shapes for streamlined analysis.

Instructions

Dissolve geometries by attribute using geopandas.dissolve. Args: gdf_path: Path to the geospatial file. by: Column to dissolve by (optional). output_path: Optional path to save the result. Returns: Dictionary with status, message, and output info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
byNo
gdf_pathYes
output_pathNo

Implementation Reference

  • The core handler function for the 'dissolve_gpd' tool. Decorated with @gis_mcp.tool() for MCP registration. Reads a GeoDataFrame, performs dissolve operation by the specified 'by' column, optionally saves output, and returns metadata and preview.
    @gis_mcp.tool() def dissolve_gpd(gdf_path: str, by: str = None, output_path: str = None) -> Dict[str, Any]: """ Dissolve geometries by attribute using geopandas.dissolve. Args: gdf_path: Path to the geospatial file. by: Column to dissolve by (optional). output_path: Optional path to save the result. Returns: Dictionary with status, message, and output info. """ try: gdf = gpd.read_file(gdf_path) result = gdf.dissolve(by=by) if output_path: output_path_resolved = resolve_path(output_path, relative_to_storage=True) output_path_resolved.parent.mkdir(parents=True, exist_ok=True) result.to_file(str(output_path_resolved)) output_path = str(output_path_resolved) preview = result.head(5).to_dict(orient="records") return { "status": "success", "message": f"Dissolve completed successfully.", "num_features": len(result), "crs": str(result.crs), "columns": list(result.columns), "preview": preview, "output_path": output_path, } except Exception as e: logger.error(f"Error in dissolve_gpd: {str(e)}") return {"status": "error", "message": str(e)}
  • Imports geopandas_functions module, which triggers registration of dissolve_gpd and other tools via their @gis_mcp.tool() decorators.
    from .geopandas_functions import * from .shapely_functions import * from .rasterio_functions import * from .pyproj_functions import * from .pysal_functions import * from .save_tool import *
  • Resource endpoint listing 'dissolve_gpd' among available GeoPandas I/O operations for tool discovery.
    @gis_mcp.resource("gis://geopandas/io") def get_geopandas_io() -> Dict[str, List[str]]: """List available GeoPandas I/O operations.""" return { "operations": [ "read_file_gpd", "to_file_gpd", "overlay_gpd", "dissolve_gpd", "explode_gpd", "clip_vector", "write_file_gpd" ] }
  • Imports geopandas_functions module in main entry point, ensuring tool registration when server starts.
    from . import ( geopandas_functions, shapely_functions, rasterio_functions, pyproj_functions, pysal_functions, )

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