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

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. """

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