Arcgis RasterCalculator
要命
private void SetGPEnvironment()
{
object obj = null;
if (m_GP == null) return;
m_GP.ClearMessages();
m_GP.OverwriteOutput = base.OverwriteOutput;
obj = m_GP.GetEnvironmentValue("OutputZFlag");
m_GP.SetEnvironmentValue("OutputZFlag", base.ZFlag.ToString());
obj = m_GP.GetEnvironmentValue("OutputMFlag");
m_GP.SetEnvironmentValue("OutputMFlag", base.MFlag.ToString());
}
private void SetGPEnvironment(RasterLayer layer)
{
SetGPEnvironment();
m_GP.SetEnvironmentValue("Extent", layer.FilePath);
}
public void RasterSubtract(RasterLayer baseMapLayer, RasterLayer toCutLayer, double radio)
{
try
{
SetGPEnvironment(baseMapLayer);
RasterCalculator RC = new RasterCalculator();
RC.expression = "\"" + baseMapLayer.FilePath + "\" - Con(IsNull(\"" + toCutLayer.FilePath + "\"),0,1)*0.3";
RC.output_raster = @"C:\Users\PC25\Documents\ArcGIS\Default.gdb\rastercalc46";
m_GP.Execute(RC, null);
object sev = null;
string str = m_GP.GetMessage(0);
MessageBox.Show(str);
}
catch (Exception ex)
{
object sev = null;
string str2=m_GP.GetMessages(ref sev);
MessageBox.Show(str2);
}
}
#endregion
转载自:https://blog.csdn.net/htsitr2/article/details/82986370