Write statisticsField in Dissolve

331
8
Jump to solution
01-10-2022 01:43 AM
DavidMrázek
Occasional Contributor II

Hello,

how to write statisticsFields in managment Dissolve correctly?

I tried it like this:

 object[] sumArea = { "Shape_Area", "SUM" };
            object[] sumLenght = { "Shape_Length", "SUM" };
            object[] statisticsFields = { sumArea, sumLenght };
  object[] listOfPara = { shpLayer, file, dissolveFields, statisticsFields, "MULTI_PART", "DISSOLVE_LINES" };
//second
 object[] statisticsFields = { "Shape_Area", "SUM" ,"Shape_Length", "SUM"}
 object[] listOfPara = { shpLayer, file, dissolveFields, statisticsFields, "MULTI_PART", "DISSOLVE_LINES" };

Both without success.

 

I will be happy for any advice.

Thank you in advance

David

0 Kudos
1 Solution

Accepted Solutions
GintautasKmieliauskas
Regular Contributor II

Hi,

Have you tried like this:

string statisticsFields = "Shape_Length SUM;Shape_Area SUM";
var parameters = Geoprocessing.MakeValueArray(shpLayer, file, dissolveFields, statisticsFields, "MULTI_PART", "DISSOLVE_LINES");
var gpResult = Geoprocessing.ExecuteToolAsync("Dissolve_management", parameters, null, CancelableProgressor.None, GPExecuteToolFlags.None);

View solution in original post

8 Replies
DanPatterson
MVP Esteemed Contributor

You have this published in the ArcGIS Pro space, hence, use python

Dissolve (Data Management)—ArcGIS Pro | Documentation

If this is for the Pro SDK I will move it


... sort of retired...
0 Kudos
DavidMrázek
Occasional Contributor II

That's what I did. But I don't know how to rewrite it in C#. Yes, it is for the ProSDK.

0 Kudos
KenBuja
MVP Esteemed Contributor

The documentation shows the statistic fields added like [[field, {statistic_type}],...], so try this:

 

object[] statisticsFields = { "Shape_Area", {"SUM"} ,"Shape_Length", {"SUM"}}

 

I used statistics fields in an ArcMap app, and while the documentation showed the same format, my code was able to use them by adding them like "Shape_Area Sum". You might want to give that syntax a try.

0 Kudos
DavidMrázek
Occasional Contributor II

Thank you for the advice, but it can't be rewritten like this.

0 Kudos
GintautasKmieliauskas
Regular Contributor II

Hi,

I would recommend to execute the same tool from ArcGIS Pro Geoprocessing pane. Then copy python script and check, how parameters looks in python script. For .NET  there is no better way to get geoprocessing function parameters. Using Geoprocessing.MakeValueArray try to get the same or similar. 

0 Kudos
DavidMrázek
Occasional Contributor II

Hi,

yes I do exactly but I don't know how to rewrite it in c # but thank you for the advice

0 Kudos
GintautasKmieliauskas
Regular Contributor II

Hi,

Have you tried like this:

string statisticsFields = "Shape_Length SUM;Shape_Area SUM";
var parameters = Geoprocessing.MakeValueArray(shpLayer, file, dissolveFields, statisticsFields, "MULTI_PART", "DISSOLVE_LINES");
var gpResult = Geoprocessing.ExecuteToolAsync("Dissolve_management", parameters, null, CancelableProgressor.None, GPExecuteToolFlags.None);
DavidMrázek
Occasional Contributor II

Hi,

Yes that's it, thank you very much! It was enough to omit the comma and combine it into one text.

0 Kudos