How do I get the Z value of a MapPoint from an elevation surface?

5202
11
04-28-2016 11:57 AM
JosephMcCausland
Esri Contributor

I'm trying to figure out how to get the elevation at a given MapPoint from a surface.  I'm getting all of my MapPoint values from a MapTool click event.  The Z value is not set at this point.  I have a TIN layer added to my map but can't find how to get the elevation from it.

0 Kudos
11 Replies
JosephMcCausland
Esri Contributor

I'm going to use "Add Surface Information" GP tool for now.  Was looking for a non GP Tool way of doing this.

0 Kudos
CharlesMacleod
Esri Regular Contributor

Hi Joseph, this is not supported in the API currently. It is planned for v1.4

0 Kudos
TedChapin
Occasional Contributor III

Charles Macleod​ is there a way to interrogate Pro's default surface with an x, y to get an elevation?

0 Kudos
by Anonymous User
Not applicable

Joseph (and Ted),

In Pro 1.3 you can now use something like a sketch point tool and examine the returned geometry for the Z value.

The Z will be taken from the current elevation environment as set in the elevation group on the Edit tab. If required you can programmatically set this environment (set z modes and select a surface) but at this time you cant add an elevation source to a surface through code.

Here's a sample point sketch tool:

  class pointSketchZ : MapTool
  {
    public pointSketchZ()
    {
      IsSketchTool = true;
      SketchType = SketchGeometryType.Point;
      SketchOutputMode = SketchOutputMode.Map;
      UseSnapping = true;
    }
    protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
    {
      return QueuedTask.Run(() =>
      {
        var mp = geometry as MapPoint;
        MessageBox.Show("X: " + mp.X + "\n" + "Y: " + mp.Y + "\n" + "Z: " + mp.Z);
        return Task.FromResult(true);
      });
    }
  }

In a future release you'll be able to query a surface with an xy to return a Z value.

0 Kudos
TedChapin
Occasional Contributor III

Sean Jones​ can the default "Ground" surface be used as the Z source for creating sketch features?  For me, Z Mode surface is disabled.

0 Kudos
by Anonymous User
Not applicable

Hi Ted,

In 2D maps there is no default elevation source set for the ground surface. With Z mode off, you'll get a value of 0 for the returned Z value. You can turn Z mode on and set a constant elevation or select a surface if you have defined an elevation source for a surface (ground or a new one).

In 3D scenes (local and globe) the world elevation service is set as an elevation source for the ground surface. If Z mode is off in these views, a Z will still be returned. You can still set a constant or choose surfaces.

To get the world elevation service in 2D views, you can add it to the ground surface (or create a new surface for it) through the map elevation surface properties. In that dialog when you click 'Add elevation source' search All Portal (in the tree on the left) for "terrain3d". This is also where you would set any local tins or grids to a surface. You can now select that surface in the edit tab to get Z values from.

0 Kudos
TedChapin
Occasional Contributor III

Pro 1.2

Even in a 3D scene, Z Mode Surface is disabled. What I'm really looking for is a bulk elevation lookup, like geocoding for elevation.

0 Kudos
by Anonymous User
Not applicable

Ah ok, I was getting ahead of myself.

In 3D views, the view (what you see is what you get) is the current surface, so you cant set additional surfaces.

For the bulk elevation lookup, I would use the 'add surface information' GP tool that Joseph mentioned earlier.

0 Kudos
TedChapin
Occasional Contributor III

How do you use the default "Ground" surface that comes with Pro as the Input Surface to Add Surface Information?

0 Kudos