Select to view content in your preferred language

Sort(Data Management) in ArcGIS Pro SDK

429
1
Jump to solution
05-24-2023 06:59 PM
tzz_12
by
New Contributor III

I am getting the hang of using Geoprocessing tools in ArcGIS Pro SDK. I am not sure how to use the sort tool in the data management toolbox, such as how to code the sort_fields for the script below to work. 

var sort_fields = new List<Tuple<string, string>> 
{
    Tuple.Create(AggregateField,"ASCENDING"),
    Tuple.Create("MUKEY","DESCENDING")
};
var para = Geoprocessing.MakeValueArray(intersectFC,intersectSortFC, sort_fields);
utility.GPRun("management.Sort", para);

 

public async void GPRun(string GPTool, IReadOnlyList<string> parameters)
{
var gp_result = await Geoprocessing.ExecuteToolAsync(GPTool, parameters);
if (gp_result.IsFailed)
{
MessageBox.Show("Error in running the Geoprocessing Tool: " + GPTool, "Geoprocessing Error");
}
}

Thanks for your help!

 

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

Geoprocessing.MakeValueArray doesn't know how to manage your sorting fields.

Try to change List<Tuple<string, string>> parameter to simple string:

var sort_fields = $"{AggregateField} ASCENDING; MUKEY DESCENDING";
var para = Geoprocessing.MakeValueArray(intersectFC,intersectSortFC, sort_fields);
utility.GPRun("management.Sort", para);

View solution in original post

1 Reply
GKmieliauskas
Esri Regular Contributor

Hi,

Geoprocessing.MakeValueArray doesn't know how to manage your sorting fields.

Try to change List<Tuple<string, string>> parameter to simple string:

var sort_fields = $"{AggregateField} ASCENDING; MUKEY DESCENDING";
var para = Geoprocessing.MakeValueArray(intersectFC,intersectSortFC, sort_fields);
utility.GPRun("management.Sort", para);