Skip to main content
Glama

append_gpd

Combine two shapefiles by vertically concatenating their data into a single output file for unified geospatial analysis.

Instructions

Reads two shapefiles directly, concatenates them vertically.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
shapefile1_pathYes
shapefile2_pathYes
output_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The append_gpd tool handler function, decorated with @gis_mcp.tool(). It reads two shapefiles into GeoDataFrames, ensures matching CRS by reprojecting if necessary, concatenates them using pd.concat, and saves the result to the specified output path as an ESRI Shapefile.
    @gis_mcp.tool()
    def append_gpd(shapefile1_path: str, shapefile2_path: str, output_path: str) -> Dict[str, Any]:
        """ Reads two shapefiles directly, concatenates them vertically."""
        try:
            # Configure a basic logger for demonstration
            logging.basicConfig(level=logging.INFO)
            logger = logging.getLogger(__name__)
    
            # Step 1: Read the two shapefiles into GeoDataFrames.
            logger.info(f"Reading {shapefile1_path}...")
            gdf1 = gpd.read_file(shapefile1_path)
            
            logger.info(f"Reading {shapefile2_path}...")
            gdf2 = gpd.read_file(shapefile2_path)
    
            # Step 2: Ensure the Coordinate Reference Systems (CRS) match.
            if gdf1.crs != gdf2.crs:
                logger.warning(
                    f"CRS mismatch: GDF1 has '{gdf1.crs}' and GDF2 has '{gdf2.crs}'. "
                    "Reprojecting GDF2."
                )
                gdf2 = gdf2.to_crs(gdf1.crs)
    
            # Step 3: Concatenate the two GeoDataFrames.
            combined_gdf = pd.concat([gdf1, gdf2], ignore_index=True)
    
            # Step 4: Save the combined GeoDataFrame to a new shapefile.
            output_path_resolved = resolve_path(output_path, relative_to_storage=True)
            output_path_resolved.parent.mkdir(parents=True, exist_ok=True)
            logger.info(f"Saving combined shapefile to {output_path_resolved}...")
            combined_gdf.to_file(str(output_path_resolved), driver='ESRI Shapefile')
    
            return {
                "status": "success",
                "message": f"Shapefiles concatenated successfully into '{output_path_resolved}'.",
                "info": {
                    "output_path": str(output_path_resolved),
                    "num_features": len(combined_gdf),
                    "crs": str(combined_gdf.crs),
                    "columns": list(combined_gdf.columns)
                }
            }
        
        except Exception as e:
            logger.error(f"Error processing shapefiles: {str(e)}")
            raise ValueError(f"Failed to process shapefiles: {str(e)}")
  • @gis_mcp.resource endpoint listing GeoPandas join operations, explicitly including "append_gpd" as an available tool.
    @gis_mcp.resource("gis://geopandas/joins")
    def get_geopandas_joins() -> Dict[str, List[str]]:
        """List available GeoPandas join operations."""
        return {
            "operations": [
                "append_gpd",
                "merge_gpd",
                "sjoin_gpd",
                "sjoin_nearest_gpd",
                "point_in_polygon"
            ]
        }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'Reads two shapefiles directly, concatenates them vertically,' which implies a read and write operation but lacks details on permissions, side effects (e.g., file creation at output_path), error handling, or performance. This is inadequate for a tool with 3 parameters and potential file I/O impacts.

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

Conciseness5/5

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

The description is a single, efficient sentence with no wasted words, clearly front-loading the core action. It's appropriately sized for the tool's complexity, making it easy to parse quickly.

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 has 3 parameters, no annotations, 0% schema coverage, but an output schema exists, the description is minimally complete. It states what the tool does but lacks details on behavior, parameters, and usage context. The output schema may help with return values, but overall, it's adequate only for basic understanding with significant gaps.

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

Parameters2/5

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

Schema description coverage is 0%, meaning parameters are undocumented in the schema. The description doesn't add any semantic information about the parameters (shapefile1_path, shapefile2_path, output_path), such as expected formats, constraints, or examples. This fails to compensate for the schema gap, leaving parameters largely unexplained.

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 action ('concatenates them vertically') and resources ('two shapefiles'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'merge_gpd' or 'concat_bands', which might have similar data combination functions, so it doesn't reach the highest score.

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 like 'merge_gpd' or 'concat_bands' from the sibling list. It mentions the action but doesn't specify use cases, prerequisites, or exclusions, leaving the agent with minimal context for 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