AnsweredAssumed Answered

How do I add rasters to a raster mosaic?

Question asked by drewdowling on May 31, 2019
Latest reply on Jul 1, 2019 by drewdowling

I'm trying to programmatically add .tif files to a raster mosaic. The code below gives a GPResult object of error type but no error messages are given so I don't know what I'm doing wrong. I can't get any other error messages or warning to trigger.

 

string inpath = Project.Current.DefaultGeodatabasePath;

string in_mosaicdataset_name = "Mosaic_name";

parameters = Geoprocessing.MakeValueArray(inpath + "\\" + in_mosaicdataset_name, "Raster Dataset", @"D:\Temp\image_982-1376.tif");
                    try
                    {
                        IGPResult gPResult = await Geoprocessing.ExecuteToolAsync(tool_path, parameters, null, _cts.Token, (event_name, o) =>  // implement delegate and handle events, o is message object.
                        {
                            switch (event_name)
                            {
                                case "OnValidate": // stop execute if any warnings
                                    MessageBox.Show(o.ToString());
                                    if ((o as IGPMessage[]).Any(it => it.Type == GPMessageType.Warning))
                                        System.Windows.MessageBox.Show(o.ToString());
                                    //_cts.Cancel();

 

                                    break;
                                case "OnProgressMessage":
                                    string msg = string.Format("{0}: {1}", new object[] { event_name, (string)o });
                                    System.Windows.MessageBox.Show(msg);
                                    //_cts.Cancel();
                                    break;
                                case "OnProgressPos":
                                    string msg2 = string.Format("{0}: {1} %", new object[] { event_name, (int)o });
                                    System.Windows.MessageBox.Show(msg2);
                                    //_cts.Cancel();
                                    break;
                            }
                        });
                        Geoprocessing.ShowMessageBox(gPResult.Messages, "GP Messages", gPResult.IsFailed ? GPMessageBoxStyle.Error : GPMessageBoxStyle.Default);

Outcomes