What data type is a Value Table in a geoprocessing tool?

402
3
04-30-2019 11:35 AM
BenRufenacht
New Contributor III

I am trying to run CalculateGeometryAttributes_management, but I can not figure out what data type to use for the

geometry_property[[Target Field, Property],...]. It appears to be an IEnumerable<KeyValuePair<string,string>>. I tried to use a dictionary, as it has this value type, but it gave me an error. Here is what I have:

Dictionary<string,string> items = new Dictionary<string, string> { "Area", "AREA" };
arguments1 = Geoprocessing.MakeValueArray(floodShape, items, "FEET_US", "SQUARE_FEET_US");
gpResult1 = Geoprocessing.ExecuteToolAsync("CalculateGeometryAttributes_management", arguments1, enviroment, null, null, GPExecuteToolFlags.None);

Anyone know what data type to use?

3 Replies
NobbirAhmed
Esri Regular Contributor

It is recommended that a user always check the tool's documentation page to make sure the data type of each parameter. For example the doc for the tool is here - you can jump to this page by clicking on the help button (? mark).

https://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-geometry-attributes.htm

There you'll find the syntax:

CalculateGeometryAttributes_management (in_features, geometry_property, {length_unit}, {area_unit}, {coordinate_system})

Below the syntax, you'll see data type of each parameter, with explanation and valid values.



0 Kudos
BenRufenacht
New Contributor III

As I said in my original question, the data type listed in the documentation is value table. My question is what data type in C# corresponds to data table. I have tried KeyValuePair, array of KeyValuePairs, lists of KeyValuePairs, and dictionaries. None of these will work.

NobbirAhmed
Esri Regular Contributor

Okay, I got it now. Here is the code that runs successfully for me:

var fields = "AAA TEXT 'A A A' 255 # #;BBB LONG 'B B B' # # #;CCC DOUBLE 'C C C' # # #";

# within double quote: field_name, field_type, field_alias, field_lenght (for string)

# for multiple fields (AddFields tool), separate two fields by semicolon

I got this syntax by running the tool via tool dialog and then drag-dropping the result from History tab to Python window.

0 Kudos