Can not create a 3D-features(have z value) using a geoprocessing package executed with Local Server

589
3
Jump to solution
09-19-2023 12:33 AM
Labels (3)
AlexanderZhang
New Contributor III

Hi,all

    I created a geoprocessing package (.gpkx) in ArcGIS Pro(3.02) involving a custom geoprocessing model that includes the Interpolate Shape (3D Analyst)  geoprocessing tool, which output a poyline 3D feature with z-value,  i executed the geoprocessing package with ArcGIS Runtime Local Server(200.1) using ArcGIS Maps SDK for .Net(200.2) , i got the poyline feature from the output, but the polyline feature is not has a z-value, and the z-values of the points("_Result") on the poyline are all 0.Can someone help me? thanks, 

  The relevant code is as follows:

 

private async void GpJobOnJobChanged(object o, JobStatus e)
        {
            // Show message if job failed
            if (_gpJob.Status == JobStatus.Failed)
            {
                 MessageBox.Show("Not found reason!", "Job Failed");
                return;
            }

            // Return if not succeeded
            if (_gpJob.Status != JobStatus.Succeeded) { return; }

            try
            {
                // Get the results from the outputs.
                GeoprocessingResult result = await _gpJob.GetResultAsync();

                var value = result.Outputs.Values.LastOrDefault() as GeoprocessingFeatures;

                IFeatureSet? gpOutputFeatures = null;

                if (value.CanGetOutputFeatures)
                    gpOutputFeatures = await value.GetOutputFeaturesAsync();
                else
                    gpOutputFeatures = value.Features ;

                List<MapPoint> mapPoints = new List<MapPoint>();

                foreach (var feature in gpOutputFeatures)
                {
                    if (feature.Geometry is Esri.ArcGISRuntime.Geometry.Polyline polyline)
                    {
                        foreach (var part in polyline.Parts)
                        {
                            mapPoints.AddRange(part.Points);
                        }
                    }
                }
                _Result = mapPoints;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
            finally
            {
                // Remove the event handlers.
                _gpJob.ProgressChanged -= GpJob_ProgressChanged;
                _gpJob.StatusChanged -= GpJobOnJobChanged;
            }

        }

 

 

0 Kudos
1 Solution

Accepted Solutions
AlexanderZhang
New Contributor III

Thank you @MichaelBranscomb for your professional information, I have solved the issue, and i may have made a rookie mistake. I found that I forgot to set the ReturnZ of the geoprocessing parameters to true, the correct code is as follows:

// Create the geoprocessing task from the service
var _gpTask = await GeoprocessingTask.CreateAsync(new Uri(_gpService.Url + "/MyGPModel"));

// Create the geoprocessing parameters
var _gpParams = await _gpTask.CreateDefaultParametersAsync();

// Set the geoprocessing parameters
_gpParams.ReturnZ = true;

 

Thanks

View solution in original post

3 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

The first thing I recommend looking at is your geoprocessing model - if you're able to share that here then we may be able to spot if there are any issues in the way it's setup.

Models are fine, but typically as your usage gets more advanced, you'll want to switch to Python scripts. I've shared an old example below. This uses a Linear Referencing tool as well, to add the distance along the line for each point (which I displayed in a client-side chart when you hover the mouse over). I would then add this Python script to a Toolbox and setup the input/output parameters (see image further below).

e.g.

import arcpy, math

inputLine = arcpy.GetParameterAsText(0)
inputRaster = arcpy.GetParameterAsText(1)
outputShapeZ = "in_memory\\outShapeZ"
outputShapeM = "in_memory\\outShapeM"

arcpy.ddd.InterpolateShape(inputRaster, inputLine, outputShapeZ)

arcpy.CreateRoutes_lr(outputShapeZ, "ident", outputShapeM, "LENGTH")

arcpy.SetParameterAsText(2, outputShapeM)

 

MichaelBranscomb_0-1695111793668.png

 

Thanks

0 Kudos
AlexanderZhang
New Contributor III

Thank you @MichaelBranscomb for your professional information, I have solved the issue, and i may have made a rookie mistake. I found that I forgot to set the ReturnZ of the geoprocessing parameters to true, the correct code is as follows:

// Create the geoprocessing task from the service
var _gpTask = await GeoprocessingTask.CreateAsync(new Uri(_gpService.Url + "/MyGPModel"));

// Create the geoprocessing parameters
var _gpParams = await _gpTask.CreateDefaultParametersAsync();

// Set the geoprocessing parameters
_gpParams.ReturnZ = true;

 

Thanks

RobertReynolds2
New Contributor II

So is there a way to create a 3-dimensional shape in ArcGIS Pro 3.1.0 with x,y,and z (z being elevaiton values) and then in geoprocessing the shape can be analyzed using IDW or kriging?  I have an Excel sheet in .csv but can't get the shape to produce, and can't analyze it in 3-d, only in 2-d.

0 Kudos