Saving results of GP tool

350
5
03-21-2019 06:53 AM
ModyBuchbinder
Esri Regular Contributor

Hello all

Some GP tools does not have a output parameter but return some kind of objects that should be saved after.

Many of the sa commands (for example Abs—Help | ArcGIS Desktop  ) return a value that must be saved.

After I run  var result = Geoprocessing.ExecuteToolAsync(...)  How do I make me result permanent?

Thanks

0 Kudos
5 Replies
GintautasKmieliauskas
Regular Contributor

Hi Mody,

Look at the piece of code below that return minimum value of specific table field. I hope it will help.

var parameters = Geoprocessing.MakeValueArray(pFeatClass, string.Format("[[{0}, MIN]]", sAreaField));

var gpResult = Geoprocessing.ExecuteToolAsync("Statistics_analysis", parameters);

double dMin = Convert.ToDouble(gpResult.Result.Values[0]);

0 Kudos
BenRufenacht
New Contributor III

That works for number outputs, but how can you save a raster output?

0 Kudos
GintautasKmieliauskas
Regular Contributor

Hi Ben,

You need to check the type of your output. Try to cast to Raster. If it is Raster then use SaveAs method.

If it is string then open it as Raster and use SaveAs method.

BenRufenacht
New Contributor III

Thanks. I was able to get the string of the raster storage path. I did not realise that these tools generated the raster results in the scratch workspace with an arbitrary name.

0 Kudos
SteveLynch
Esri Regular Contributor

...for large output you may want to rather use your output workspace in place of the scratch workspace so that save will internally do a rename rather than a copy.

0 Kudos