You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A .NET library for Digital Elevation Model (DEM) processing. It provides elevation queries, contour line generation, hillshading and support for multiple data formats and on-demand HTTP data sources.
Installation
dotnet add package Pmad.Cartography
Getting started
Query elevation from a well-known database
// Uses SRTM1 data hosted on cdn.dem.pmad.net (downloaded on demand and cached locally)vardatabase=WellKnownDatabases.GetSRTM1();// Single point - bilinear interpolationvarelevation=awaitdatabase.GetElevationAsync(newCoordinates(51.509865,-0.118092),DefaultInterpolation.Instance);// Load an area into memory as a float rastervararea=awaitdatabase.CreateView<float>(newCoordinates(51,-1),newCoordinates(52,0));
Elevation contours
varcontour=newContourGraph();// 10-metre interval starting at 10 mcontour.Add(area,newContourLevelGenerator(10,10));foreach(varlineincontour.Lines){Console.WriteLine($"Level {line.Level}: {line.Points.Count} points");}
Hillshading
// Each pixel of 'area' represents a 10x10-metre cellvarhillshader=newHillshaderFast(newVector2D(10,10));// Returns an RGBA image where alpha encodes shadow intensityImage<Rgba32>img=hillshader.GetPixelsAlphaBelowFlat(area);
Data sources
The following open datasets are pre-configured in WellKnownDatabases: