Skip to main content
Glama

explode_gpd

Split multi-part geospatial geometries into individual components for analysis. Converts complex geographic data into separate features using geopandas.explode.

Instructions

Split multi-part geometries into single parts using geopandas.explode. Args: gdf_path: Path to the geospatial file. output_path: Optional path to save the result. Returns: Dictionary with status, message, and output info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gdf_pathYes
output_pathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core implementation of the 'explode_gpd' MCP tool: loads GeoDataFrame, explodes multi-part geometries, optionally saves output, returns metadata and preview.
    @gis_mcp.tool()
    def explode_gpd(gdf_path: str, output_path: str = None) -> Dict[str, Any]:
        """
        Split multi-part geometries into single parts using geopandas.explode.
        Args:
            gdf_path: Path to the geospatial file.
            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.explode(index_parts=True, ignore_index=True)
            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)
            # Convert geometry to WKT for serialization
            preview_df = result.head(5).copy()
            if 'geometry' in preview_df.columns:
                preview_df['geometry'] = preview_df['geometry'].apply(lambda g: g.wkt if g is not None else None)
            preview = preview_df.to_dict(orient="records")
            return {
                "status": "success",
                "message": "Explode 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 explode_gpd: {str(e)}")
            return {"status": "error", "message": str(e)}
  • Import of geopandas_functions module in __init__.py, which triggers the @gis_mcp.tool() decorator to register the 'explode_gpd' tool.
    from .geopandas_functions import *
  • MCP resource listing GeoPandas I/O tools, including 'explode_gpd', discoverable at gis://geopandas/io.
    @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"
            ]
        }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the action ('split') and returns a dictionary with status, message, and output info, but lacks critical details: whether the tool modifies the original file, what happens if output_path is null, error conditions (e.g., invalid geometries), or performance implications. For a mutation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded: the first sentence states the purpose clearly, followed by brief sections for Args and Returns. There's no wasted text, though the Args and Returns sections are terse. Every sentence adds value, making it efficient for an agent to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (geometry splitting), lack of annotations, and an output schema (implied by 'Returns' but not detailed), the description is partially complete. It covers the basic purpose and parameters but misses behavioral context (e.g., side effects, errors) and deeper usage guidelines. The presence of an output schema helps, but the description doesn't fully compensate for the missing annotations and low schema coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the schema provides no parameter details. The description adds minimal semantics: it names the parameters ('gdf_path', 'output_path') and states that output_path is optional, but doesn't explain what a 'geospatial file' entails (e.g., formats like GeoJSON, Shapefile), path requirements, or what 'output info' includes. This partially compensates but leaves key aspects undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Split multi-part geometries into single parts using geopandas.explode.' This specifies the verb ('split'), resource ('multi-part geometries'), and method ('using geopandas.explode'), making it distinct from siblings like 'dissolve_gpd' or 'merge_gpd'. However, it doesn't explicitly differentiate from tools like 'unary_union_geometries' that also handle geometry decomposition.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., input must be a valid geospatial file), exclusions (e.g., not for raster data), or sibling tools that might be more appropriate for related tasks like geometry simplification or union operations. The agent must infer usage from the purpose alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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