Select to view content in your preferred language

Run a Chain of Geoprocessing without adding temporary output to display

662
1
Jump to solution
08-20-2020 09:31 AM
DouglasLong
Regular Contributor

New to the ArcGIS SDK, I am running a chain of geoprocessing steps, even though I am writing the dataset to memory, each step is being added to the Display and the Table of Contents. Ideally, I would like to hide all that until after the processing is done.

I can delete the features at the end, but there has to be a better way.

        private Task BasicSample(ProgressorSource status)
        {
            return QueuedTask.Run((Action)(async () => {

                var envArray = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true, cellSize: 1);

                // make a value array of strings to be passed to ExecuteToolAsync
                var parameters = Geoprocessing.MakeValueArray(SelectedPolygonLayer, "memory\\copy_poly");
                var copyFc = await Geoprocessing.ExecuteToolAsync("CopyFeatures_management", parameters);
                var outFc = copyFc.Values[0];

                var parameters1 = Geoprocessing.MakeValueArray(outFc, "xtcx", "SHORT");
                var addFieldResult = await Geoprocessing.ExecuteToolAsync("AddField_management", parameters1);

                // calculate the field
                var parameters2 = Geoprocessing.MakeValueArray(outFc, "xtcx", 1);
                var calcField = await Geoprocessing.ExecuteToolAsync("CalculateField_management", parameters2);

                // convert polygon to raster
                string outRaster = System.IO.Path.Combine(Project.Current.DefaultGeodatabasePath, "outRas");
                var polyToRasterValueArray = Geoprocessing.MakeValueArray(outFc, "xtcx", outRaster);
                await Geoprocessing.ExecuteToolAsync("PolygonToRaster_conversion", polyToRasterValueArray, envArray);

                var deleteArray = Geoprocessing.MakeValueArray(new List<string>() { outFc});
                var deleteFcs = await Geoprocessing.ExecuteToolAsync("Delete_management", deleteArray);

            }));
        }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
1 Solution

Accepted Solutions
NobbirAhmed
Esri Regular Contributor

Geoprocessing.ExecuteToolAsync has several optional parameters - the full syntax is:

var GPResult = Geoprocessing.ExecuteToolAsync(tool_path, parameters, envArray, null, null, GPExecuteToolFlags.None);

Passing GPExecuteToolFlags.None as the last parameter will block adding output to the map.

View solution in original post

1 Reply
NobbirAhmed
Esri Regular Contributor

Geoprocessing.ExecuteToolAsync has several optional parameters - the full syntax is:

var GPResult = Geoprocessing.ExecuteToolAsync(tool_path, parameters, envArray, null, null, GPExecuteToolFlags.None);

Passing GPExecuteToolFlags.None as the last parameter will block adding output to the map.