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);
Solved! Go to Solution.
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.
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.
Thanks a lot! After I changed the order of the parameter, it worked like a charm!