Select to view content in your preferred language

Create Raster Dataset tool doesn't work for GDB

1003
6
05-28-2019 07:38 AM
MaxMax2
Frequent Contributor

It seems that 'Create Raster Dataset' geoprocessing tool doesn't work at all for GDB, either programmatically or not. My code:

var args = Geoprocessing.MakeValueArray(datastorePath, RasterDatasetName, null, "8_BIT_SIGNED", null, 3);
var env = Geoprocessing.MakeEnvironmentArray(outputCoordinateSystem: SpatialReferences.WGS84);
var gpResult = await Geoprocessing.ExecuteToolAsync("CreateRasterDataset_management", args, env, can

When tool executing, program crashes. If I try to create raster dataset manually in ArcGIS Pro, ArcGIS Pro crashes.

How can I create raster dataset in GDB?

0 Kudos
6 Replies
DrewDowling
Frequent Contributor

This code works for me, but creating a mosaic dataset

string inpath = Project.Current.DefaultGeodatabasePath;
string in_mosaicdataset_name = rasterseriesname;
var sr = await QueuedTask.Run(() => {
       return SpatialReferenceBuilder.CreateSpatialReference(3857);
});

var parameters = Geoprocessing.MakeValueArray(inpath, in_mosaicdataset_name, sr, "3", "8_BIT_UNSIGNED", "NATURAL_COLOR_RGB");
string tool_path = "management.CreateMosaicDataset";
System.Threading.CancellationTokenSource _cts = new System.Threading.CancellationTokenSource();
IGPResult result = 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
                                if ((o as IGPMessage[]).Any(it => it.Type == GPMessageType.Warning))
                                    _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;
        }
});

0 Kudos
NobbirAhmed
Esri Regular Contributor

Nothing would work in SDK if that does not work in the main app (ArcGIS Pro). I just tested on our recent setup and it works (I mean I could create a Raster Dataset). 

@Max Max - which version of ArcGIS Pro you are on?

0 Kudos
MaxMax2
Frequent Contributor

I'm on 2.3.

0 Kudos
MaxMax2
Frequent Contributor

Screenshot for bad case:

As for project it's just new one without any added layers except the default Topographic. If you run the tool with parameters from screenshot, ArcGIS Pro will crash.

0 Kudos
NobbirAhmed
Esri Regular Contributor

I cannot reproduce in later version. Right now I'm on 2.4 and it runs without any errors.

0 Kudos
MaxMax2
Frequent Contributor

OK, but I need to support earlier versions too. In my case I can easily work around the problem using WGS84 spatial reference. So just instead of default map's spatial reference I specify WGS84 (from added layer with this SR) and tool works.

Thanks for fixing this in 2.4.

0 Kudos