Skip to main content
Glama

overlay_gpd

Combine two geospatial datasets using overlay operations like intersection, union, or difference to analyze spatial relationships and create new geographic features.

Instructions

Overlay two GeoDataFrames using geopandas.overlay. Args: gdf1_path: Path to the first geospatial file. gdf2_path: Path to the second geospatial file. how: Overlay method ('intersection', 'union', 'identity', 'symmetric_difference', 'difference'). output_path: Optional path to save the result. Returns: Dictionary with status, message, and output info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gdf1_pathYes
gdf2_pathYes
howNointersection
output_pathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function implementing the 'overlay_gpd' MCP tool. It reads two geospatial files, performs a spatial overlay operation using geopandas.overlay with the specified method, optionally saves the result, and returns metadata and a preview.
    @gis_mcp.tool()
    def overlay_gpd(gdf1_path: str, gdf2_path: str, how: str = "intersection", output_path: str = None) -> Dict[str, Any]:
        """
        Overlay two GeoDataFrames using geopandas.overlay.
        Args:
            gdf1_path: Path to the first geospatial file.
            gdf2_path: Path to the second geospatial file.
            how: Overlay method ('intersection', 'union', 'identity', 'symmetric_difference', 'difference').
            output_path: Optional path to save the result.
        Returns:
            Dictionary with status, message, and output info.
        """
        try:
            gdf1 = gpd.read_file(gdf1_path)
            gdf2 = gpd.read_file(gdf2_path)
            if gdf1.crs != gdf2.crs:
                gdf2 = gdf2.to_crs(gdf1.crs)
            result = gpd.overlay(gdf1, gdf2, how=how)
            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": f"Overlay ({how}) 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 overlay_gpd: {str(e)}")
            return {"status": "error", "message": str(e)}
  • MCP resource listing that documents 'overlay_gpd' as one of the available GeoPandas I/O operations, serving as a schema or directory 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"
            ]
        }
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. It mentions that the tool performs an overlay operation and returns a dictionary, but doesn't disclose critical behavioral traits such as whether it modifies input files, requires specific permissions, handles errors, or has performance implications. For a tool with no annotations, this is a significant gap in transparency.

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 appropriately sized and front-loaded, starting with the core purpose. The Args and Returns sections are structured for clarity, though the 'Args' label is slightly informal. Every sentence adds value, with no wasted words, 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 complexity (spatial overlay with multiple methods), no annotations, and an output schema (implied by 'Returns'), the description is moderately complete. It covers parameters well but lacks behavioral context and usage guidelines. The presence of an output schema means the description doesn't need to detail return values, but overall it's adequate with clear gaps.

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

Parameters4/5

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

The description adds substantial meaning beyond the input schema, which has 0% description coverage. It explains that 'gdf1_path' and 'gdf2_path' are paths to geospatial files, 'how' is the overlay method with specific options, and 'output_path' is optional for saving results. This compensates well for the schema's lack of descriptions, though it doesn't detail file format requirements or method nuances.

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: 'Overlay two GeoDataFrames using geopandas.overlay.' This specifies the verb ('overlay'), the resource ('GeoDataFrames'), and the method ('geopandas.overlay'). It distinguishes from siblings like 'intersection' or 'union' by being a more general overlay operation with multiple methods, though it doesn't explicitly contrast with them.

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?

No guidance is provided on when to use this tool versus alternatives. The description lists parameters and returns but doesn't mention when to choose this over sibling tools like 'intersection', 'union', or 'difference', or when to use it for spatial analysis tasks. This leaves the agent without context for tool selection.

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