Skip to main content
Glama

hillshade

Create shaded relief maps from elevation data to visualize terrain features and enhance topographic analysis in GIS applications.

Instructions

Generate hillshade from a DEM raster. Args: raster_path: Path to the DEM raster. azimuth: Sun azimuth angle in degrees. angle_altitude: Sun altitude angle in degrees. output_path: Optional path to save the hillshade raster. Returns: Dictionary with status, message, and output path if saved.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
raster_pathYes
azimuthNo
angle_altitudeNo
output_pathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function for the 'hillshade' tool. Computes hillshade illumination from a DEM raster using numpy's gradient for slope/aspect and trigonometric shading model. Supports optional output saving.
    @gis_mcp.tool()
    def hillshade(raster_path: str, azimuth: float = 315, angle_altitude: float = 45, output_path: str = None) -> Dict[str, Any]:
        """
        Generate hillshade from a DEM raster.
        Args:
            raster_path: Path to the DEM raster.
            azimuth: Sun azimuth angle in degrees.
            angle_altitude: Sun altitude angle in degrees.
            output_path: Optional path to save the hillshade raster.
        Returns:
            Dictionary with status, message, and output path if saved.
        """
        try:
            import rasterio
            import numpy as np
            with rasterio.open(raster_path) as src:
                elevation = src.read(1).astype('float32')
                profile = src.profile.copy()
                x, y = np.gradient(elevation, src.res[0], src.res[1])
                slope = np.pi/2 - np.arctan(np.sqrt(x*x + y*y))
                aspect = np.arctan2(-x, y)
                az = np.deg2rad(azimuth)
                alt = np.deg2rad(angle_altitude)
                shaded = np.sin(alt) * np.sin(slope) + np.cos(alt) * np.cos(slope) * np.cos(az - aspect)
                hillshade = np.clip(255 * shaded, 0, 255).astype('uint8')
            if output_path:
                output_path_resolved = resolve_path(output_path, relative_to_storage=True)
                output_path_resolved.parent.mkdir(parents=True, exist_ok=True)
                profile.update(dtype='uint8', count=1)
                with rasterio.open(str(output_path_resolved), "w", **profile) as dst:
                    dst.write(hillshade, 1)
                output_path = str(output_path_resolved)
            return {
                "status": "success",
                "message": "Hillshade generated successfully.",
                "output_path": output_path
            }
        except Exception as e:
            logger.error(f"Error in hillshade: {str(e)}")
            return {"status": "error", "message": str(e)}
  • Resource endpoint listing 'hillshade' among available rasterio operations, indicating tool availability.
    @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"
            ]
        }
  • Input schema and documentation for hillshade tool parameters and return value.
    """
    Generate hillshade from a DEM raster.
    Args:
        raster_path: Path to the DEM raster.
        azimuth: Sun azimuth angle in degrees.
        angle_altitude: Sun altitude angle in degrees.
        output_path: Optional path to save the hillshade raster.
    Returns:
        Dictionary with status, message, and output path if saved.
    """
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 that the tool generates a hillshade and returns a dictionary with status, message, and output path, but lacks critical details: it doesn't specify if this is a read-only or destructive operation, what happens if the output_path is null (e.g., in-memory processing), error handling, or performance considerations like processing time or memory usage. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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 appropriately sized: it starts with a clear purpose statement, followed by organized sections for 'Args' and 'Returns'. Each sentence adds value without redundancy. It could be slightly more front-loaded by integrating key parameter details into the opening, but overall, it's efficient and easy 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 complexity (a raster processing tool with 4 parameters), no annotations, and an output schema (implied by the 'Returns' section), the description is moderately complete. It covers the purpose and parameters but lacks behavioral context (e.g., side effects, error cases) and doesn't fully explain the return dictionary's structure beyond high-level fields. With no annotations to fill gaps, it should do more to be fully comprehensive.

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 schema description coverage is 0%, so the description must compensate by explaining parameters. It does this effectively: it lists all four parameters (raster_path, azimuth, angle_altitude, output_path) with brief semantics (e.g., 'Sun azimuth angle in degrees'), clarifying their roles beyond the schema's basic types. However, it doesn't provide examples or constraints (e.g., valid ranges for angles), preventing a perfect score.

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: 'Generate hillshade from a DEM raster.' It specifies the verb ('Generate') and resource ('hillshade from a DEM raster'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'reproject_raster' or 'raster_algebra', which could also process DEM rasters, 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. It doesn't mention prerequisites, such as needing a valid DEM raster file, or compare it to similar tools in the sibling list (e.g., 'compute_ndvi' for other raster analyses). Without any context on usage scenarios or exclusions, it falls short of providing meaningful guidance.

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