Skip to main content
Left closed in review as "Original close reason(s) were not resolved" by Midavalo
added 58 characters in body
Added to review
Source Link

The code below with 3 parameters fails to run slope tool and get expected result. No error is shown. Just expected result doesn't come out.

 public SlopeTool(string inRaster, string outRasterName, string workspace, string 
 prjFilePath)
 {
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
 }

 public async Task<IGpResult> ExecuteAsync()
 {
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster, "PERCENT_RISE", 1
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

 }
 catch (Exception ex)
 {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
 }
 }

But this code below runs and succeeds with the single parameter

public SlopeTool(string inRaster, string outRasterName, string workspace, string 
prjFilePath)
{
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
}

public async Task<IGpResult> ExecuteAsync()
{
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

    }
    catch (Exception ex)
    {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
    }
 }

I can also run it in ArcGIS Pro Python command line this way

arcpy.sa.Slope('DEM_AB_Clip1.tif', 'PERCENT_RISE', 1)

What is the problem in my 1st code with 3 parameters and how to get expected result?

The code below with 3 parameters fails to run slope tool and get expected result

 public SlopeTool(string inRaster, string outRasterName, string workspace, string 
 prjFilePath)
 {
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
 }

 public async Task<IGpResult> ExecuteAsync()
 {
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster, "PERCENT_RISE", 1
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

 }
 catch (Exception ex)
 {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
 }
 }

But this code below runs and succeeds with the single parameter

public SlopeTool(string inRaster, string outRasterName, string workspace, string 
prjFilePath)
{
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
}

public async Task<IGpResult> ExecuteAsync()
{
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

    }
    catch (Exception ex)
    {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
    }
 }

I can also run it in ArcGIS Pro Python command line this way

arcpy.sa.Slope('DEM_AB_Clip1.tif', 'PERCENT_RISE', 1)

What is the problem in my 1st code with 3 parameters and how to get expected result?

The code below with 3 parameters fails to run slope tool and get expected result. No error is shown. Just expected result doesn't come out.

 public SlopeTool(string inRaster, string outRasterName, string workspace, string 
 prjFilePath)
 {
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
 }

 public async Task<IGpResult> ExecuteAsync()
 {
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster, "PERCENT_RISE", 1
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

 }
 catch (Exception ex)
 {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
 }
 }

But this code below runs and succeeds with the single parameter

public SlopeTool(string inRaster, string outRasterName, string workspace, string 
prjFilePath)
{
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
}

public async Task<IGpResult> ExecuteAsync()
{
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

    }
    catch (Exception ex)
    {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
    }
 }

I can also run it in ArcGIS Pro Python command line this way

arcpy.sa.Slope('DEM_AB_Clip1.tif', 'PERCENT_RISE', 1)

What is the problem in my 1st code with 3 parameters and how to get expected result?

Post Closed as "Needs details or clarity" by TomazicM, Vince, Cyril Mikhalchenko, PolyGeo
edited tags
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
naming
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

The code below with 3 parameters fails to run slope tool and get expected result

 public SlopeTool(string inRaster, string outRasterName, string workspace, string 
 prjFilePath)
 {
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
 }

 public async Task<IGpResult> ExecuteAsync()
 {
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster, "PERCENT_RISE", 1
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

 }
 catch (Exception ex)
 {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
 }
 }

But this code below runs and succeeds with the single parameter

public SlopeTool(string inRaster, string outRasterName, string workspace, string 
prjFilePath)
{
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
}

public async Task<IGpResult> ExecuteAsync()
{
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

    }
    catch (Exception ex)
    {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
    }
 }

I can also run it in Arcgis pro pythonArcGIS Pro Python command line this way

arcpy.sa.Slope('DEM_AB_Clip1.tif', 'PERCENT_RISE', 1)

What is the problem in my 1st code with 3 parameters and how to get expected result  ?

The code below with 3 parameters fails to run slope tool and get expected result

 public SlopeTool(string inRaster, string outRasterName, string workspace, string 
 prjFilePath)
 {
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
 }

 public async Task<IGpResult> ExecuteAsync()
 {
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster, "PERCENT_RISE", 1
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

 }
 catch (Exception ex)
 {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
 }
 }

But this code below runs and succeeds with the single parameter

public SlopeTool(string inRaster, string outRasterName, string workspace, string 
prjFilePath)
{
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
}

public async Task<IGpResult> ExecuteAsync()
{
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

    }
    catch (Exception ex)
    {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
    }
 }

I can also run it in Arcgis pro python command line this way

arcpy.sa.Slope('DEM_AB_Clip1.tif', 'PERCENT_RISE', 1)

What is the problem in my 1st code with 3 parameters and how to get expected result  ?

The code below with 3 parameters fails to run slope tool and get expected result

 public SlopeTool(string inRaster, string outRasterName, string workspace, string 
 prjFilePath)
 {
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
 }

 public async Task<IGpResult> ExecuteAsync()
 {
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster, "PERCENT_RISE", 1
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

 }
 catch (Exception ex)
 {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
 }
 }

But this code below runs and succeeds with the single parameter

public SlopeTool(string inRaster, string outRasterName, string workspace, string 
prjFilePath)
{
 _inRaster = inRaster;
 _outRasterName = outRasterName;
 _workspace = workspace;
 _prjFilePath = prjFilePath;
}

public async Task<IGpResult> ExecuteAsync()
{
 try
 {
     var slopeToolParameters = Geoprocessing.MakeValueArray(
         _inRaster
     );

     var gpResult = await Geoprocessing.ExecuteToolAsync("sa.Slope", 
     slopeToolParameters);

     if (gpResult.IsFailed)
     {
         MessageBox.Show("Tool Failed");
     }
     return new GpResult(gpResult);

    }
    catch (Exception ex)
    {
     MessageBox.Show($@"Error during Slope Tool operation: {ex.Message}");
     return new GpResult(null);
    }
 }

I can also run it in ArcGIS Pro Python command line this way

arcpy.sa.Slope('DEM_AB_Clip1.tif', 'PERCENT_RISE', 1)

What is the problem in my 1st code with 3 parameters and how to get expected result?

Added language tag
Source Link
Hornbydd
  • 44.6k
  • 5
  • 42
  • 84
Loading
Source Link
Loading