Adding Z values to Geometry

01-13-2017 06:56 AM
New Contributor III

Using ArcGIS Runtime for .NET 100.0 and WPF. I have a geometry created using the sketch editor ...

       _traceGeometry = await Mapview.SketchEditor.StartAsync(SketchCreationMode.Polyline, true);

Then later I want to create a feature using this geometry. However, the feature class has z values. So when I try to save it via ...

      await table.AddFeaturesAsync(features);

I get an exception: "The shape must have a Z value."

My question is how can I add z values to this geometry? Do I need to recreate a new geometry using PolylineBuilder and adding a z-value for each point?

Initially all points can (and should) have 0 for a z-value, but eventually, we will run a calculation that adds z-values based on underlying elevation.

Alternatively, will the sketch editor create a z-enabled geometry if there is underlying elevation data included as a map layer?

0 Kudos
1 Reply
Esri Frequent Contributor

Yes, you would have to go through the geometry in a builder and assign appropriate Z values to the vertices. The editor doesn't try and "guess" a Z value automatically, but forces the developer to make an informed decision about what Z values are correct, rather than risk inserting invalid geometry into your database. We are looking at making this easier (like for instance allowing you to set a default Z and/or M value)

MapView doesn't have an elevation source, and thus can't derive it from there either (and that would still mean making an assumption about what you're sketching that might be wrong).

0 Kudos