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);
}));
}
Solved! Go to Solution.
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.
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.