Skip to main content
Glama

raster_band_statistics

Calculate min, max, mean, and standard deviation statistics for each band of a raster image to analyze geospatial data patterns.

Instructions

Calculate min, max, mean, and std for each band of a raster.

Parameters:

  • source: path to input raster (local or URL).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that implements the core logic of the raster_band_statistics tool. It reads the input raster, computes min, max, mean, and standard deviation for each band using rasterio and numpy, handling masked arrays for NoData values, and returns a dictionary with the statistics.
    def raster_band_statistics(
        source: str
    ) -> Dict[str, Any]:
        """
        Calculate min, max, mean, and std for each band of a raster.
    
        Parameters:
        - source: path to input raster (local or URL).
        """
        try:
            import numpy as np
            import rasterio
    
            src_path = os.path.expanduser(source.replace("`", ""))
            stats = {}
    
            with rasterio.open(src_path) as src:
                for i in range(1, src.count + 1):
                    band = src.read(i, masked=True)  # masked array handles NoData
                    stats[f"Band {i}"] = {
                        "min": float(band.min()),
                        "max": float(band.max()),
                        "mean": float(band.mean()),
                        "std": float(band.std())
                    }
    
            return {
                "status": "success",
                "statistics": stats,
                "message": f"Band-wise statistics computed successfully."
            }
    
        except Exception as e:
            raise ValueError(f"Failed to compute statistics: {e}")
  • The raster_band_statistics tool is registered/listed as one of the available rasterio operations in this resource endpoint.
    @gis_mcp.resource("gis://operation/rasterio")
    def get_rasterio_operations() -> Dict[str, List[str]]:
        """List available rasterio operations."""
        return {
            "operations": [
                "metadata_raster",
                "get_raster_crs",
                "clip_raster_with_shapefile",
                "resample_raster",
                "reproject_raster",
                "weighted_band_sum",
                "concat_bands",
                "raster_algebra",
                "compute_ndvi",
                "raster_histogram",
                "tile_raster",
                "raster_band_statistics",
                "extract_band",
                "zonal_statistics",
                "reclassify_raster",
                "focal_statistics",
                "hillshade",
                "write_raster"
            ]
        }
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 the calculation action but lacks details on permissions, rate limits, computational intensity, or output format. While it implies a read-only operation (calculating statistics), it doesn't confirm safety or describe potential side effects, leaving significant gaps for a tool with no annotation coverage.

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 efficiently structured with a clear purpose statement followed by parameter details in a bulleted format. Both sentences earn their place by defining the tool's function and its key input. It could be slightly more front-loaded by integrating the parameter info, but overall it's concise with minimal waste.

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 (statistical calculation on raster data), no annotations, and an output schema present, the description is minimally adequate. It covers the basic purpose and parameter but lacks behavioral context and usage guidance. The output schema reduces the need to explain return values, but the description doesn't fully compensate for the missing annotations and sibling tool context.

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 meaningful context for the single parameter 'source,' explaining it as 'path to input raster (local or URL).' This clarifies the parameter's purpose and acceptable values beyond the schema's basic string type. With 0% schema description coverage and only one parameter, this compensation is effective, though not exhaustive (e.g., no format examples).

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: 'Calculate min, max, mean, and std for each band of a raster.' This specifies the verb (calculate) and resource (raster bands) with precise statistical outputs. However, it doesn't explicitly differentiate from sibling tools like 'raster_histogram' or 'metadata_raster' that might provide related raster information, preventing a perfect 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. It doesn't mention sibling tools like 'raster_histogram' for distribution analysis or 'metadata_raster' for general raster info, nor does it specify prerequisites or contexts for choosing this statistical calculation over others. Only basic parameter usage is implied.

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