<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Elevation not loaded + Profile Job in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/elevation-not-loaded-profile-job/m-p/1161090#M10881</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to get the elevation at a point using code very similar to&amp;nbsp;&lt;A href="https://developers.arcgis.com/net/winui/sample-code/get-elevation-at-a-point/" target="_blank"&gt;Get elevation at a point | ArcGIS Runtime API for .NET | ArcGIS Developer&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;However the following throws an exception "Elevation must be loaded before you can get the elevation".&lt;/P&gt;&lt;P&gt;I am behind a proxy, could that be getting in the way of this working?&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public class ArcGisAdapter
    {
        Surface Surface = new Surface();
        Uri _elevationUri = new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");
        public async System.Threading.Tasks.Task&amp;lt;bool&amp;gt; InitializeAsync()
        {
            ArcGISRuntimeEnvironment.ApiKey = "&amp;lt;mykey&amp;gt;";
            
            ArcGISRuntimeEnvironment.Initialize();

            Surface.ElevationSources.Add(new ArcGISTiledElevationSource(_elevationUri));
            await Surface.LoadAsync();
            if (( Surface.LoadStatus == LoadStatus.FailedToLoad ) ||
                    Surface.LoadStatus == LoadStatus.NotLoaded)
            {
                Console.WriteLine($"Failed to load {Surface.LoadError.Message}");
                return false;
            }
            else
            {
                Console.WriteLine($"Loaded elevation {Surface.LoadStatus.ToString()}");
                return true;
            }
        }

        public async System.Threading.Tasks.Task&amp;lt;double&amp;gt; GetElevation()
        {
            try
            {
                // Get the elevation value.
                var point = new MapPoint(83.9, 28.42);
                var elevation = await Surface.GetElevationAsync(point);

                // Set the text displaying the elevation.
                Console.WriteLine($"{Math.Round(elevation)} m");
                return elevation;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return -1;
            }
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;Stack trace:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichaelVowles_0-1649159195084.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/38130i140AA2E08F637505/image-size/large?v=v2&amp;amp;px=999" role="button" title="MichaelVowles_0-1649159195084.png" alt="MichaelVowles_0-1649159195084.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Apr 2022 11:50:37 GMT</pubDate>
    <dc:creator>MichaelVowles</dc:creator>
    <dc:date>2022-04-05T11:50:37Z</dc:date>
    <item>
      <title>Elevation not loaded + Profile Job</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/elevation-not-loaded-profile-job/m-p/1161090#M10881</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to get the elevation at a point using code very similar to&amp;nbsp;&lt;A href="https://developers.arcgis.com/net/winui/sample-code/get-elevation-at-a-point/" target="_blank"&gt;Get elevation at a point | ArcGIS Runtime API for .NET | ArcGIS Developer&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;However the following throws an exception "Elevation must be loaded before you can get the elevation".&lt;/P&gt;&lt;P&gt;I am behind a proxy, could that be getting in the way of this working?&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public class ArcGisAdapter
    {
        Surface Surface = new Surface();
        Uri _elevationUri = new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");
        public async System.Threading.Tasks.Task&amp;lt;bool&amp;gt; InitializeAsync()
        {
            ArcGISRuntimeEnvironment.ApiKey = "&amp;lt;mykey&amp;gt;";
            
            ArcGISRuntimeEnvironment.Initialize();

            Surface.ElevationSources.Add(new ArcGISTiledElevationSource(_elevationUri));
            await Surface.LoadAsync();
            if (( Surface.LoadStatus == LoadStatus.FailedToLoad ) ||
                    Surface.LoadStatus == LoadStatus.NotLoaded)
            {
                Console.WriteLine($"Failed to load {Surface.LoadError.Message}");
                return false;
            }
            else
            {
                Console.WriteLine($"Loaded elevation {Surface.LoadStatus.ToString()}");
                return true;
            }
        }

        public async System.Threading.Tasks.Task&amp;lt;double&amp;gt; GetElevation()
        {
            try
            {
                // Get the elevation value.
                var point = new MapPoint(83.9, 28.42);
                var elevation = await Surface.GetElevationAsync(point);

                // Set the text displaying the elevation.
                Console.WriteLine($"{Math.Round(elevation)} m");
                return elevation;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return -1;
            }
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;Stack trace:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichaelVowles_0-1649159195084.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/38130i140AA2E08F637505/image-size/large?v=v2&amp;amp;px=999" role="button" title="MichaelVowles_0-1649159195084.png" alt="MichaelVowles_0-1649159195084.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 11:50:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/elevation-not-loaded-profile-job/m-p/1161090#M10881</guid>
      <dc:creator>MichaelVowles</dc:creator>
      <dc:date>2022-04-05T11:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Elevation not loaded + Profile Job</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/elevation-not-loaded-profile-job/m-p/1162254#M10888</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/575566"&gt;@MichaelVowles&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thank you for reaching out to us. After taking a look at your code, I have a quick question.&lt;/P&gt;&lt;P&gt;Where are you calling your `GetElevation()` from? Without getting a broader context, it seems like you are loading the surface on a different thread than where you're trying to get the elevation from the surface? What happens if you move these two lines&lt;/P&gt;&lt;PRE&gt;var point = new MapPoint(83.9, 28.42);
var elevation = await Surface.GetElevationAsync(point);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;to after the&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;await Surface.LoadAsync();&lt;/PRE&gt;&lt;P&gt;in the InitializeAsync() func?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 18:44:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/elevation-not-loaded-profile-job/m-p/1162254#M10888</guid>
      <dc:creator>KoushikHajra</dc:creator>
      <dc:date>2022-04-07T18:44:04Z</dc:date>
    </item>
  </channel>
</rss>

