Create RasterDataset

1056
6
11-27-2019 05:09 PM
by Anonymous User
Not applicable

Hi,

I came across some sample of updating raster data with ArcGIS pro sdk.

ProSnippets Raster · Esri/arcgis-pro-sdk Wiki · GitHub 

But I didn't manage to find the sample or guidance of creation of raster file from scratch such as with folder connection or file geodatabase.

So Would like to know how to create raster dataset with folder connection or file geodatabase creation.

Will be appreciated if it is possible with ArcGIS runtime sdk .net. And I am not fun of calling the python geoprocessing task from the pro sdk .net as well.

Tags (1)
0 Kudos
6 Replies
GKmieliauskas
Esri Regular Contributor

Hi Than,

You can do it in ArcGIS Pro SDK .Net using geoprocessing:

var gpResult = Geoprocessing.ExecuteToolAsync("CreateRasterDataset_management", ...,

    ..., ..., ..., ...);

If you want to get help with ArcGIS Runtime sdk you are in the wrong forum. You can get more feedback in ArcGIS Runtime sdk forums.

by Anonymous User
Not applicable

Thank Gintautas,

Any .net sample of those Geoprocessing tool?

Is that idea to continue calling geoprocessing tool from sdk or extension code? and no roadmap to have managed code?

I believed in ArcObject we have that features in the framework.

For ArcGIS runtime sdk for .net , if there is no build in support with ArcGIS pro sdk, I am thinking of creating Raster dataset and reload it from ArcGIS pro extension.

0 Kudos
GKmieliauskas
Esri Regular Contributor

Hi Than,

Sample code:

IReadOnlyList<string> parameters = Geoprocessing.MakeValueArray("D:\Temp\Test", // Output path
 "Result", // Raster name
 50, // Cellsize
 "8_BIT_UNSIGNED", // pixel type
 spatRef, // Spatial reference,
 1); // Bands count
IReadOnlyList<KeyValuePair<string, string>> environments = Geoprocessing.MakeEnvironmentArray(extent: pEnvelope);
var gpResult = Geoprocessing.ExecuteToolAsync("CreateRasterDataset_management", parameters, environments,
                    CancelableProgressor.None, GPExecuteToolFlags.GPThread);
gpResult.Wait();
More info about parameters and environment here:
And forget about ArcObjects when you are working with ArcGIS Pro.
by Anonymous User
Not applicable

Thank for your sample code with Geoprocessing call,

Is that the practice to call Geoprocessing tool in ArcGIS pro sdk when it is not natively supported?

And I believed it is running under different thread and how shall we troubleshoot when thing went wrong?

Like file locked by Geoprocessing thread?

Is that try cach enough?

By looking at outcome, yes it is working with these code.

Will there be implication if ArcGIS pro is upgraded to another version with few enhancement to these tool?

With SDK we will know these straight upon compilation but those Geoprocessing tool call coding how shall  we trace the update?

Or am I overly thinking and those tools will never be changed?

0 Kudos
GKmieliauskas
Esri Regular Contributor

In ArcGIS Pro database structure editing, raster creation and analysis and much more functionality are realized using geoprocessing. For small task it is enough, but for big applications it takes a lot time to start geoprocessing. To troubleshoot geoprocessing check geoprocessing messages after executing tool:

// gp_result is the returned result object from a call to ExecuteToolAsync
// displays error messages if the tool fails, otherwise shows the default messages
Geoprocessing.ShowMessageBox(gp_result.Messages, "GP Messages",
                gp_result.IsFailed ? GPMessageBoxStyle.Error : GPMessageBoxStyle.Default);

More info:

https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Geoprocessing

Other questions could be answered by Esri stuff only

by Anonymous User
Not applicable

Thank Gintautas,

Your comments help me a lot, 

Seem Geoprocessing object is quite useful for that sdk to reuse the prebaked tool.

As per my previous comment, have concern with these and didn't dive into it.

string ExportTifFile = FileName + ".tif";
                    var parameters = Geoprocessing.MakeValueArray(
                         this.InputModel.DestinationPath, // Output path
                        ExportTifFile, // Raster name : make it as tif file
                         rasterInfo.CellSize.ToString(), // Cellsize
                         this.InputModel.PixelType, // pixel type
                         this._lastSelectedSR, // Spatial reference,
                         1); // Bands count

                    //IReadOnlyList<KeyValuePair<string, string>> environments = Geoprocessing.MakeEnvironmentArray(extent: pEnvelope);
                    var gpResult = Geoprocessing.ExecuteToolAsync("CreateRasterDataset_management", parameters, null,
                                        CancelableProgressor.None, GPExecuteToolFlags.GPThread);
                    gpResult.Wait();
                    IGPResult ProcessingResult =  gpResult.Result;
                    if (ProcessingResult.IsFailed)
                    {
                       foreach(IGPMessage message in ProcessingResult.Messages)
                        {
                            ConversionToolModule.Current.ModuleLogManager.LogError("Error on create raster dataset tool calling");
                            ConversionToolModule.Current.ModuleLogManager.LogError($"{{Error Code: {message.ErrorCode}, Text :  {message.Text} }}");
                        }
                        Geoprocessing.ShowMessageBox(ProcessingResult.Messages, "Raster creation error", GPMessageBoxStyle.Error);
                    }
0 Kudos