Skip to content

dem-net/Samples

Repository files navigation

Board Status

DEM-Net Samples

Summary

Please note that the DEM tiles will be downloaded on first run if they are not present on the local system.

Get Elevation on SRTM_GL3 dataset from a location (lat/lng) :

// download missing DEM files if necessary
ElevationService.DownloadMissingFiles(DEMDataSet.SRTM_GL3, lat, lon);

// get elevation
GeoPoint point = ElevationService.GetPointElevation(lat, lon, DEMDataSet.SRTM_GL3);
double? elevation = point.Elevation;

Get Elevation from multiple locations at once :

This sample get elevations for all line/DEM intersections (it can return a LOT of points). The line can be generalized and return only points where elevation change is relevant AND keeping the local maximas.

IEnumerable<GeoPoint> geoPoints = ElevationService.GetPointsElevation(points, dataSet);

Get line elevation :

This sample get elevations for all line/DEM intersections (it can return a LOT of points). The line can be generalized and return only points where elevation change is relevant AND keeping the local maximas.

// Straight line crossing exactly Mt Ventoux peak
var elevationLine = GeometryService.ParseGeoPointAsGeometryLine(new GeoPoint(44.078873, 5.144899), new GeoPoint(44.225876, 5.351516));

// Download DEM tiles if necessary
ElevationService.DownloadMissingFiles(DEMDataSet.AW3D30, elevationLine.GetBoundingBox());

// Get line elevation : 1274 points !
var geoPoints = ElevationService.GetLineGeometryElevation(elevationLine, dataSet);

// Compute metrics (to get distance from origin)
var metrics = geoPoints.ComputeMetrics();

// Simplify line with 50m resolution
var simplified = DouglasPeucker.DouglasPeuckerReduction(geoPoints.ToList(), 50 /* meters */);

//
// Now we have only 20 points but all the peaks and coves
//

Get elevations for a GPX track

// Read GPX points and flatten the segments into a list of points
var gpxFile = Path.Combine("SampleData", "lauzannier.gpx");
var points = GpxImport.ReadGPX_Segments(gpxFile)
                      .SelectMany(segment => segment);

 // Retrieve elevation for each point on DEM
List<GeoPoint> gpxPointsElevated = ElevationService.GetPointsElevation(points, DEMDataSet.AW3D30)
                                        .ToList();

A DEM.Net Dataset is a public data source of DEM files. DEM.Net supports global datasets in OpenTopography.org.

Get a report of all downloaded files

RasterService.GenerateReportAsString();

This will produce this nice output :

GenerateReportAsString

glTF 3D samples

DEMDataSet dataset = DEMDataSet.AW3D30;
var modelName = $"Montagne Sainte Victoire {dataset.Name}";

// You can get your boox from https://geojson.net/ (save as WKT)
string bboxWKT = "POLYGON((5.54888 43.519525, 5.61209 43.519525, 5.61209 43.565225, 5.54888 43.565225, 5.54888 43.519525))";
var bbox = GeometryService.GetBoundingBox(bboxWKT);
var heightMap = _elevationService.GetHeightMap(bbox, dataset)
		.ReprojectGeodeticToCartesian() // Reproject to 3857 (useful to get coordinates in meters)
		.ZScale(2f)                     // Elevation exageration
		.CenterOnOrigin();

// Triangulate height map
var mesh = _glTFService.GenerateTriangleMesh(heightMap);
var model = _glTFService.GenerateModel(mesh, modelName);

// Export Binary model file
_glTFService.Export(model, Directory.GetCurrentDirectory(), modelName, exportglTF: false, exportGLB: true);

This will run in less than 500ms and produce this nice model (you can natively open it in Windows 10's 3D viewer):

ste.gif

All elevations are linked together as a triangle mesh.

STL samples

Docs coming soon...

Imagery samples

Docs coming soon...

About

DEM.Net Samples

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy