WhiteRom
WhiteRom

Reputation: 73

How to get elevation in point using dted tif file offline in .Net?

I'm trying to get elevation in specific points from a local file that has dted tif file format. Using Esri.ArcGISRuntime library I get the error - "Null pointer: Elevation must be loaded before you can get elevation". Maybe someone has tips - is this possible using Esri.ArcGISRuntime? Or maybe there are other libraries that could help? Below code snippet:

'''

        //parentFolder - folder with dted.tif file 
        List<string> files = Directory.EnumerateFiles(parentFolder, "*.*", SearchOption.AllDirectories).ToList();

        var surface = new Esri.ArcGISRuntime.Mapping.Surface();
        RasterElevationSource rasterElevationSource = new RasterElevationSource(files);

        surface.ElevationSources.Add(rasterElevationSource);
        surface.LoadAsync().GetAwaiter().GetResult();

        //lat, lon - some random coordinates
        var mp = new Esri.ArcGISRuntime.Geometry.MapPoint(lat, lon);           
        var res = surface.GetElevationAsync(mp).GetAwaiter().GetResult();
        Console.WriteLine($"Elevation: {res}");

'''

Upvotes: 0

Views: 143

Answers (0)

Related Questions