DTED as a local elevation source (.NET, WPF, V100.0)

3233
8
03-21-2017 07:53 AM
KeithGemeinhart1
New Contributor III

I'm looking for a way to use DTED data as a local elevation source in a WPF application and v100.0 of the runtime. Our application needs to have it on the local drive since internet connection is not always available.

0 Kudos
8 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

The DTED format works in the same way as any other raster format supported as an elevation source. You define them as RasterElevationSource objects and add them to the Scene's BaseSurface ElevationSources collection. You should be able to do something like:

```

string parentFolder = @"C:\Data\DTED0";
List<string> files = Directory.EnumerateFiles(parentFolder, "*.dt0", SearchOption.AllDirectories).ToList();

Scene.BaseSurface = new Surface();
RasterElevationSource rasterElevationSource = new RasterElevationSource(files);

Scene.BaseSurface.ElevationSources.Add(rasterElevationSource);

```

Cheers

Mike

0 Kudos
MarkCammarere
New Contributor III

Mike: I am trying to do this as well (get elevation values from a DTED1 surface) and have the following code (which is pretty similar to what you show above. (In this code dted1Files is an enumeration of DTED1 tiles and args.Location is a MapPoint - obtained via mouse click on a 2D map, not a scene.)

RasterElevationSource dted1ElevSource = new RasterElevationSource(dted1Files);
await dted1ElevSource.LoadAsync();

dted1ElevSource.Name = "DTED1";

Surface elevSurface = new Surface();
elevSurface.ElevationSources.Add(dted1ElevSource);
elevSurface.Name = "DTED1 Surface";
await elevSurface.LoadAsync();

Scene dtedScene = new Scene();
dtedScene.BaseSurface = elevSurface;
await dtedScene.LoadAsync();

double anElevation = await elevSurface.GetElevationAsync(args.Location);

However, I get a null exception error on the last line (elevSurface.GetElevationAsync). The message on the error states that 'Elevation must be in a scene view before getting elevation'.Any thoughts on what I'm missing? Any insights are much appreciated. Thanks!

Mark

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi Mark,

Is your Scene in a SceneView?

My code snippet assumed that `Scene` was a ViewModel property bound to SceneView.Scene in the View. 

Cheers

Mike

0 Kudos
MarkCammarere
New Contributor III

Mike: Sorry, I didn't notice your reply. Initially, it was not in a SceneView. I added that, and now I can get elevation values OK. Thanks for you help!

Mark

0 Kudos
KeithGemeinhart1
New Contributor III

Is there a way to do this with a MapView or only with a SceneView?

0 Kudos
MarkCammarere
New Contributor III

This is a reply to myself (and also for the consumption of anyone else who might be trying to do the above). I added the following right before the last line of code in my post above:

SceneView aSceneView = new SceneView();
aSceneView.Scene = dtedScene;

...and was successful in getting an elevation value from the surface! The only thing I'm still trying to sort out is a possible projection issue. The spatial reference of the scene is WKID 4326 (WGS-84), but the spatial reference of the MapPoint that I'm passing into the GetElevationAsync method is WKID 3857 (Web Mercator Aux Sphere). So ... I'm getting a valid elevation, but am not sure if its for the correct spot in the scene. Does anyone know if Scene/SceneView does on-the-fly projection if the input MapPoint is in a different projection?

Mark

0 Kudos
MarkCammarere
New Contributor III

Another reply to self. Scene/SceneView apparently does support on-the-fly projection. I get the same elevation value whether I re-project the input MapPoint or not.

0 Kudos
dotMorten_esri
Esri Notable Contributor

I get the same elevation value whether I re-project the input MapPoint or not.

That proves the input mappoint is automatically projected to the SR it needs (ie so that it does indeed understand that the two point locations represents the same physical location).

0 Kudos