Pmad.Cartography
0.1.23
dotnet add package Pmad.Cartography --version 0.1.23
NuGet\Install-Package Pmad.Cartography -Version 0.1.23
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pmad.Cartography" Version="0.1.23" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pmad.Cartography" Version="0.1.23" />
<PackageReference Include="Pmad.Cartography" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Pmad.Cartography --version 0.1.23
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Pmad.Cartography, 0.1.23"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Pmad.Cartography@0.1.23
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Pmad.Cartography&version=0.1.23
#tool nuget:?package=Pmad.Cartography&version=0.1.23
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Pmad.Cartography
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)
var database = WellKnownDatabases.GetSRTM1();
// Single point - bilinear interpolation
var elevation = await database.GetElevationAsync(
new Coordinates(51.509865, -0.118092),
DefaultInterpolation.Instance);
// Load an area into memory as a float raster
var area = await database.CreateView<float>(
new Coordinates(51, -1),
new Coordinates(52, 0));
Elevation contours
var contour = new ContourGraph();
// 10-metre interval starting at 10 m
contour.Add(area, new ContourLevelGenerator(10, 10));
foreach (var line in contour.Lines)
{
Console.WriteLine($"Level {line.Level}: {line.Points.Count} points");
}
Hillshading
// Each pixel of 'area' represents a 10x10-metre cell
var hillshader = new HillshaderFast(new Vector2D(10, 10));
// Returns an RGBA image where alpha encodes shadow intensity
Image<Rgba32> img = hillshader.GetPixelsAlphaBelowFlat(area);
Data sources
The following open datasets are pre-configured in WellKnownDatabases:
| Source | Resolution | License | Credits |
|---|---|---|---|
| SRTM1 | 1 arc second | Public Domain | NASA |
| SRTM15+ | 15 arc seconds | Public Domain | Tozer et al. |
| AW3D30 | 1 arc second | See terms | (c) JAXA |
Data is fetched over HTTP from cdn.dem.pmad.net and cached locally. You can supply a custom cache path:
var database = WellKnownDatabases.GetSRTM1(localCache: @"C:\dem-cache");
File formats
Supported raster formats
| Format | Read | Write | Notes |
|---|---|---|---|
| ESRI ASCII | Yes | Yes | float only |
| DDC | Yes | Yes | Native format for this library |
| GeoTIFF | Yes | WGS84 projection only | |
| SRTM HGT | Yes | 1 and 3 arc-second |
Supported compression wrappers
| Format | Read | Write | Notes |
|---|---|---|---|
| ZSTD | Yes | Yes | Best storage/CPU trade-off (default) |
| GZip | Yes | Yes | Lowest CPU cost |
| Brotli | Yes | Yes | Best compression ratio |
| Zip | Yes | Archive must contain a single file |
Key types
| Type | Description |
|---|---|
DemDatabase |
Main entry point - wraps a storage and provides async elevation/view queries |
WellKnownDatabases |
Factory helpers for the pre-configured CDN datasets |
DemDataCell<T> |
In-memory raster tile with typed pixel values |
ContourGraph |
Builds a set of contour lines from a raster view |
ContourLevelGenerator |
Defines the interval and starting elevation for contour generation |
HillshaderFast |
Fast hillshading using the Zevenbergen-Thorne gradient algorithm |
HillshaderClassic |
Reference hillshader (slower, same visual output) |
HillshaderIgor |
Alternative hillshader with a different lighting model |
DefaultInterpolation |
Bilinear elevation interpolation between raster pixels |
Coordinates |
WGS84 latitude/longitude coordinate pair |
DemFileSystemStorage |
Reads a DEM database from a local directory |
DemHttpStorage |
Downloads DEM tiles on demand from an HTTP server with local caching |
Dependencies
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- BitMiracle.LibTiff.NET (>= 2.4.649)
- GeoJSON.Text (>= 1.0.2)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Pmad.Geometry (>= 0.1.46)
- SixLabors.ImageSharp (>= 3.1.11)
- System.Text.Json (>= 8.0.5)
- ZstdSharp.Port (>= 0.8.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Pmad.Cartography:
| Package | Downloads |
|---|---|
|
Pmad.Cartography.Drawing
Library for drawing maps with PDF, PNG/WEBP and SVG support. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Pmad.Cartography:
| Repository | Stars |
|---|---|
|
jetelain/ArmaRealMap
Tools to generate realistic Arma3 terrain from OpenStreetMap data in an highly automated process.
|