Skip to content

Instantly share code, notes, and snippets.

@BrunoCaimar
Last active April 6, 2017 12:00
Show Gist options
  • Save BrunoCaimar/b3a29b4eb6a69e73935bc78e7b33481e to your computer and use it in GitHub Desktop.
Save BrunoCaimar/b3a29b4eb6a69e73935bc78e7b33481e to your computer and use it in GitHub Desktop.
Running a geoprocess inside C# (AO)
public void SampleCalculateBestPathToolGping()
{
// Initialize the geoprocessor.
IGeoProcessor2 gp=new GeoProcessorClass();
// Add the BestPath toolbox.
gp.AddToolbox(@"C:\SanDiego\BestPath.tbx");
// Generate the array of parameters.
IVariantArray parameters=new VarArrayClass();
parameters.Add(@"C:\SanDiego\source.shp");
parameters.Add(@"C:\SanDiego\destination.shp");
parameters.Add(@"C:\SanDiego\bestpath.shp");
object sev=null;
try
{
// Execute the model tool by name.
gp.Execute("CalculateBestPath", parameters, null);
Console.WriteLine(gp.GetMessages(ref sev));
}
catch (Exception)
{
// Print geoprocessing execution error messages.
Console.WriteLine(gp.GetMessages(ref sev));
throw;
}
}
@BrunoCaimar
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment