Select to view content in your preferred language

Create constant raster GP tool always failed

54
2
Jump to solution
Monday
AquanuityDevelopment
New Contributor III

I'm having trouble getting the Create Constant Raster GP tool to work using the Pro SDK. Below is a snippet of my code. Could you help me identify what I'm doing wrong? Any assistance would be greatly appreciated.

var parameters = Geoprocessing.MakeValueArray(2.6, @"C:\temp\test.tif", "FLOAT", 100.0, pEnp);

var cts = new CancellationTokenSource();
var results = await Geoprocessing.ExecuteToolAsync("CreateConstantRaster_sa", parameters, null, cts.Token,
(eventName, o) =>
{
}, GPExecuteToolFlags.None);

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

Guessing the order of parameters in a Spatial Analyst function is a great art. In your case output parameter is first. To find reason why your geoprocessing fails add few lines:

            var parameters = Geoprocessing.MakeValueArray(@"C:\temp\test.tif", 2.6, "FLOAT", 100.0, pEnp);

            var cts = new CancellationTokenSource();
            var results = await Geoprocessing.ExecuteToolAsync("CreateConstantRaster_sa", parameters, null, cts.Token,
            (eventName, o) =>
            {
                System.Diagnostics.Debug.WriteLine($@"GP event: {eventName}");
                if (eventName == "OnMessage" || eventName == "OnValidate")
                {

                    System.Diagnostics.Debug.WriteLine($@"Msg: {o}");
                }
            }, GPExecuteToolFlags.None);

More info here.

View solution in original post

2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Guessing the order of parameters in a Spatial Analyst function is a great art. In your case output parameter is first. To find reason why your geoprocessing fails add few lines:

            var parameters = Geoprocessing.MakeValueArray(@"C:\temp\test.tif", 2.6, "FLOAT", 100.0, pEnp);

            var cts = new CancellationTokenSource();
            var results = await Geoprocessing.ExecuteToolAsync("CreateConstantRaster_sa", parameters, null, cts.Token,
            (eventName, o) =>
            {
                System.Diagnostics.Debug.WriteLine($@"GP event: {eventName}");
                if (eventName == "OnMessage" || eventName == "OnValidate")
                {

                    System.Diagnostics.Debug.WriteLine($@"Msg: {o}");
                }
            }, GPExecuteToolFlags.None);

More info here.

AquanuityDevelopment
New Contributor III

 

Thanks a lot!  After I changed the order of the parameter, it worked like a charm!

0 Kudos