Skip to main content
Glama

hillshade

Generate hillshade visualizations from DEM rasters by specifying azimuth and altitude angles for light source. Enhances terrain analysis and mapping clarity.

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
angle_altitudeNo
azimuthNo
output_pathNo
raster_pathYes

Implementation Reference

  • The main handler function for the 'hillshade' tool, decorated with @gis_mcp.tool(). It computes hillshade illumination from a DEM raster using numpy gradients for slope/aspect and trigonometric shading model based on sun azimuth and altitude.
    @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)}
  • 'hillshade' is registered/listed as one of the available rasterio operations in this MCP 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" ] }

Other Tools

Related 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