Skip to content

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 necessaryElevationService.DownloadMissingFiles(DEMDataSet.SRTM_GL3,lat,lon);// get elevationGeoPointpoint=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 peakvarelevationLine=GeometryService.ParseGeoPointAsGeometryLine(newGeoPoint(44.078873,5.144899),newGeoPoint(44.225876,5.351516));// Download DEM tiles if necessaryElevationService.DownloadMissingFiles(DEMDataSet.AW3D30,elevationLine.GetBoundingBox());// Get line elevation : 1274 points !vargeoPoints=ElevationService.GetLineGeometryElevation(elevationLine,dataSet);// Compute metrics (to get distance from origin)varmetrics=geoPoints.ComputeMetrics();// Simplify line with 50m resolutionvarsimplified=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 pointsvargpxFile=Path.Combine("SampleData","lauzannier.gpx");varpoints=GpxImport.ReadGPX_Segments(gpxFile).SelectMany(segment =>segment);// Retrieve elevation for each point on DEMList<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

DEMDataSetdataset=DEMDataSet.AW3D30;varmodelName=$"Montagne Sainte Victoire {dataset.Name}";// You can get your boox from https://geojson.net/ (save as WKT)stringbboxWKT="POLYGON((5.54888 43.519525, 5.61209 43.519525, 5.61209 43.565225, 5.54888 43.565225, 5.54888 43.519525))";varbbox=GeometryService.GetBoundingBox(bboxWKT);varheightMap=_elevationService.GetHeightMap(bbox,dataset).ReprojectGeodeticToCartesian()// Reproject to 3857 (useful to get coordinates in meters).ZScale(2f)// Elevation exageration.CenterOnOrigin();// Triangulate height mapvarmesh=_glTFService.GenerateTriangleMesh(heightMap);varmodel=_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

7 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages