I have been having fits trying to get SplineWithBarriers to work but to no avail.
My environment:
Windows 7 64 bit
Visual Studio 2010 Team Edition
ArcMap
Release Version 10.0
Product Version: 10.0.2.3200
Spatial Analyst License
Should also mention this is C# code.
I have tried all I can think of and everything looks correct except I continue to get an "E_FAIL" exception whenever it is run. I am hoping someone on this forum has done this and is able to point out my problems. Thanks for any and all help.
Following is my full method.
private void DoSplineWithBarriers()
{
SplineWithBarriers swb = new SplineWithBarriers();
IWorkspaceFactory wksFact;
IFeatureWorkspace featWks;
IFeatureClass inPtsFC;
IGeoFeatureLayer geoFeatLyr;
wksFact = new ShapefileWorkspaceFactoryClass();
featWks = wksFact.OpenFromFile("C:\\Workarea\\swb", 0) as IFeatureWorkspace;
inPtsFC = featWks.OpenFeatureClass("pointsFeature");
geoFeatLyr = new FeatureLayerClass();
geoFeatLyr.Name = inPtsFC.AliasName;
geoFeatLyr.FeatureClass = inPtsFC;
featWks = wksFact.OpenFromFile("C:\\Workarea\\swb", 0) as
IFeatureWorkspace;
IFeatureClass barriers;
barriers = featWks.OpenFeatureClass("barrierFeature");
Raster outPutRas = new Raster();
swb.Input_point_features = (object)inPtsFC;
swb.Z_value_field = (object)"DEPTH";
swb.Output_raster = (object)outPutRas;
swb.Input_barrier_features = (object)barriers;
swb.Output_cell_size = (object)0;
swb.Smoothing_Factor = 0.0;
swb.ToolboxDirectory = "C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\ArcToolbox\\Toolboxes";
Geoprocessor gp = new Geoprocessor();
gp.AddOutputsToMap = false;
try
{
gp.Execute(swb, null);
}
catch (Exception ex)
{
string msg = "";
msg = String.Format("Exception creating spline: {0}\r\nStack trace:\r\n{1}",
ex.Message, ex.StackTrace);
}
}