English

FAQ: How do I run Business Analyst tools using ArcGIS Pro .NET SDK with a specific datasource?

Question

How do I run Business Analyst tools using ArcGIS Pro .NET SDK with a specific datasource?

Answer

Even though the baDataSource Environment Variable is not supported by MakeEnvironmentArray method, it can be can passed to ExecuteToolAsync. To do this, just create a list of key-value pairs, for example:

  protected override void OnClick()
    {
      var parameters = Geoprocessing.MakeValueArray("populationtotals.totpop_cy", "2019 Total Population Layer Local", "NATURAL_BREAKS", "5");

      var env = new List>() { new KeyValuePair("baDataSource", "LOCAL;;USA_ESRI_2019") };

      var gp_result = Geoprocessing.ExecuteToolAsync("ba.ColorCodedLayer", parameters, env, flags:GPExecuteToolFlags.AddToHistory | GPExecuteToolFlags.AddOutputsToMap);

      parameters = Geoprocessing.MakeValueArray("populationtotals.totpop_cy", "2019 Total Population Layer Online", "NATURAL_BREAKS", "5");

      env = new List>() { new KeyValuePair("baDataSource", "ONLINE;US;") };

      gp_result = Geoprocessing.ExecuteToolAsync("ba.ColorCodedLayer", parameters, env, flags: GPExecuteToolFlags.AddToHistory | GPExecuteToolFlags.AddOutputsToMap);