本文整理汇总了C#中IRaster.IsFullyWindowed方法的典型用法代码示例。如果您正苦于以下问题:C# IRaster.IsFullyWindowed方法的具体用法?C# IRaster.IsFullyWindowed怎么用?C# IRaster.IsFullyWindowed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRaster
的用法示例。
在下文中一共展示了IRaster.IsFullyWindowed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Slope
/// <summary>
/// Executes the slope generation raster.
/// </summary>
/// <param name="ras">The input altitude raster.</param>
/// <param name="inZFactor">The multiplicitive scaling factor for elveation.</param>
/// <param name="slopeInPercent">Boolean that is true if the slope values should be returned as percentages.</param>
/// <param name="result">The output slope raster.</param>
/// <param name="cancelProgressHandler">The progress handler.</param>
/// <returns>Boolean, true if the method was successful.</returns>
private static bool Slope(
ref IRaster ras,
double inZFactor,
bool slopeInPercent,
ref IRaster result,
ICancelProgressHandler cancelProgressHandler)
{
// Validates the input and output data
if (ras == null || result == null)
{
return false;
}
try
{
int noOfCol = ras.NumColumns;
int noOfRow = ras.NumRows;
// Create the new raster with the appropriate dimensions
IRaster temp = Raster.CreateRaster(
"SlopeRaster.bgd", string.Empty, noOfCol, noOfRow, 1, typeof(double), new[] { string.Empty });
temp.NoDataValue = ras.NoDataValue;
temp.Bounds = ras.Bounds;
for (int i = 0; i < temp.NumRows; i++)
{
for (int j = 0; j < temp.NumColumns; j++)
{
if (i > 0 && i < temp.NumRows - 1 && j > 0 && j < temp.NumColumns - 1)
{
double z1 = ras.Value[i - 1, j - 1];
double z2 = ras.Value[i - 1, j];
double z3 = ras.Value[i - 1, j + 1];
double z4 = ras.Value[i, j - 1];
double z5 = ras.Value[i, j + 1];
double z6 = ras.Value[i + 1, j - 1];
double z7 = ras.Value[i + 1, j];
double z8 = ras.Value[i + 1, j + 1];
// 3rd Order Finite Difference slope algorithm
double dZdX = inZFactor * ((z3 - z1) + 2 * (z5 - z4) + (z8 - z6)) / (8 * ras.CellWidth);
double dZdY = inZFactor * ((z1 - z6) + 2 * (z2 - z7) + (z3 - z8)) / (8 * ras.CellHeight);
double slope = Math.Atan(Math.Sqrt((dZdX * dZdX) + (dZdY * dZdY))) * (180 / Math.PI);
// change to radious and in persentage
if (slopeInPercent)
{
slope = Math.Tan(slope * Math.PI / 180) * 100;
}
temp.Value[i, j] = slope;
if (cancelProgressHandler.Cancel)
{
return false;
}
}
else
{
temp.Value[i, j] = temp.NoDataValue;
}
if (cancelProgressHandler.Cancel)
{
return false;
}
}
}
result = temp;
if (result.IsFullyWindowed())
{
result.Save();
return true;
}
return false;
}
catch (Exception ex)
{
// throw new SystemException("Error in Slope: ", ex);
throw new SystemException(ex.ToString());
}
}
示例2: GetSlope
/// <summary>
/// Executes the slope generation raster.
/// </summary>
/// <param name="raster">The input altitude raster.</param>
/// <param name="inZFactor">The double precision multiplicative scaling factor for elevation values.</param>
/// <param name="slopeInPercent">A boolean parameter that clarifies the nature of the slope values. If this is true, the values represent percent slope.</param>
/// <param name="result">The output slope raster.</param>
/// <param name="cancelProgressHandler">The progress handler.</param>
/// <returns>A boolean value, true if the process was successful.</returns>
public static bool GetSlope(IRaster raster, double inZFactor, bool slopeInPercent, ref IRaster result,
ICancelProgressHandler cancelProgressHandler)
{
//Validates the input and output data
if (raster == null || result == null)
{
return false;
}
int noOfCol = raster.NumColumns;
int noOfRow = raster.NumRows;
//Create the new raster with the appropriate dimensions
IRaster temp = Raster.CreateRaster("SlopeRaster.bgd", string.Empty, noOfCol, noOfRow, 1, typeof(double),
new[] { string.Empty });
temp.NoDataValue = raster.NoDataValue;
temp.Bounds = raster.Bounds;
temp.Projection = raster.Projection;
ProgressMeter progMeter = null;
try
{
if (cancelProgressHandler != null)
progMeter = new ProgressMeter(cancelProgressHandler, "Calculating Slope", temp.NumRows);
for (int i = 0; i < temp.NumRows; i++)
{
if (cancelProgressHandler != null)
{
progMeter.Next();
if ((i % 100) == 0)
{
progMeter.SendProgress();
// HACK: DoEvents messes up the normal flow of your application.
System.Windows.Forms.Application.DoEvents();
}
}
for (int j = 0; j < temp.NumColumns; j++)
{
if (i > 0 && i < temp.NumRows - 1 && j > 0 && j < temp.NumColumns - 1)
{
double z1 = raster.Value[i - 1, j - 1];
double z2 = raster.Value[i - 1, j];
double z3 = raster.Value[i - 1, j + 1];
double z4 = raster.Value[i, j - 1];
double z5 = raster.Value[i, j + 1];
double z6 = raster.Value[i + 1, j - 1];
double z7 = raster.Value[i + 1, j];
double z8 = raster.Value[i + 1, j + 1];
//3rd Order Finite Difference slope algorithm
double dZdX = inZFactor * ((z3 - z1) + (2 * (z5 - z4)) + (z8 - z6)) / (8 * raster.CellWidth);
double dZdY = inZFactor * ((z1 - z6) + (2 * (z2 - z7)) + (z3 - z8)) / (8 * raster.CellHeight);
double slope = Math.Atan(Math.Sqrt((dZdX * dZdX) + (dZdY * dZdY))) * (180 / Math.PI);
//change to radius and in percentage
if (slopeInPercent)
{
slope = (Math.Tan(slope * Math.PI / 180)) * 100;
}
temp.Value[i, j] = slope;
if (cancelProgressHandler != null && cancelProgressHandler.Cancel)
{
return false;
}
}
else
{
temp.Value[i, j] = temp.NoDataValue;
}
if (cancelProgressHandler != null && cancelProgressHandler.Cancel)
{
return false;
}
}
}
result = temp;
if (result.IsFullyWindowed())
{
result.Save();
return true;
}
return false;
}
//.........这里部分代码省略.........
示例3: Execute
/// <summary>
/// Executes the slope generation raster.
/// </summary>
/// <param name="ras">The input altitude raster.</param>
/// <param name="inZFactor">A multiplicative scaling factor to be applied to the elevation values before calculating the slope.</param>
/// <param name="slopeInPercent">If this is true, the resulting slopes are returned as percentages.</param>
/// <param name="output">The output slope raster.</param>
/// <param name="cancelProgressHandler">The progress handler.</param>
/// <returns>True if the method worked.</returns>
public bool Execute(
IRaster ras,
double inZFactor,
bool slopeInPercent,
IRaster output,
ICancelProgressHandler cancelProgressHandler)
{
// Validates the input and output data
if (ras == null || output == null)
{
return false;
}
try
{
int noOfCol = ras.NumColumns;
int noOfRow = ras.NumRows;
output = Raster.CreateRaster(
output.Filename, string.Empty, noOfCol, noOfRow, 1, typeof(double), new[] { string.Empty });
output.NoDataValue = ras.NoDataValue;
// output.Bounds = ras.Bounds.Copy();
output.Bounds = ras.Bounds;
int previous = 0;
for (int i = 0; i < output.NumRows; i++)
{
int current = Convert.ToInt32(Math.Round(i * 100D / output.NumRows));
// only update when increment in percentage
if (current > previous)
{
cancelProgressHandler.Progress(string.Empty, current, current + TextStrings.progresscompleted);
}
previous = current;
for (int j = 0; j < output.NumColumns; j++)
{
if (i > 0 && i < output.NumRows - 1 && j > 0 && j < output.NumColumns - 1)
{
double z1 = ras.Value[i - 1, j - 1];
double z2 = ras.Value[i - 1, j];
double z3 = ras.Value[i - 1, j + 1];
double z4 = ras.Value[i, j - 1];
double z5 = ras.Value[i, j + 1];
double z6 = ras.Value[i + 1, j - 1];
double z7 = ras.Value[i + 1, j];
double z8 = ras.Value[i + 1, j + 1];
// 3rd Order Finite Difference slope algorithm
double dZdX = inZFactor * ((z3 - z1) + 2 * (z5 - z4) + (z8 - z6)) / (8 * ras.CellWidth);
double dZdY = inZFactor * ((z1 - z6) + 2 * (z2 - z7) + (z3 - z8)) / (8 * ras.CellHeight);
double slope = Math.Atan(Math.Sqrt((dZdX * dZdX) + (dZdY * dZdY))) * (180 / Math.PI);
// change to radious and in persentage
if (slopeInPercent)
{
slope = Math.Tan(slope * Math.PI / 180) * 100;
}
output.Value[i, j] = slope;
if (cancelProgressHandler.Cancel)
{
return false;
}
}
else
{
output.Value[i, j] = output.NoDataValue;
}
if (cancelProgressHandler.Cancel)
{
return false;
}
}
}
// output = Temp;
if (output.IsFullyWindowed())
{
output.Save();
return true;
}
return false;
}
catch (Exception ex)
//.........这里部分代码省略.........
示例4: Execute
/// <summary>
/// Executes the slope generation raster.
/// </summary>
/// <param name="ras">The input altitude raster.</param>
/// <param name="output">The output slope raster.</param>
/// <param name="cancelProgressHandler">The progress handler.</param>
/// <returns></returns>
public bool Execute(IRaster ras,double inZFactor, bool slopeInPercent,IRaster output, MapWindow.Tools.ICancelProgressHandler cancelProgressHandler)
{
//Validates the input and output data
if (ras == null || output == null)
{
return false;
}
double z1, z2, z3, z4, z5, z6, z7, z8, dZ_dx, dZ_dy, slope;
int current, previous;
try
{
int noOfCol = ras.NumColumns;
int noOfRow = ras.NumRows;
IEnvelope envelope1 = new Envelope() as IEnvelope;
envelope1 = ras.Bounds.Envelope;
output = Raster.Create(output.Filename, "", noOfCol, noOfRow, 1, typeof(double), new string[] { "" });
output.NoDataValue = ras.NoDataValue;
//output.Bounds = ras.Bounds.Copy();
output.Bounds = ras.Bounds;
previous = 0;
for (int i = 0; i < output.NumRows; i++)
{
current = Convert.ToInt32(Math.Round(i * 100D / output.NumRows));
//only update when increment in percentage
if (current > previous)
cancelProgressHandler.Progress("", current, current.ToString() + TextStrings.progresscompleted);
previous = current;
for (int j = 0; j < output.NumColumns; j++)
{
if (i > 0 && i < output.NumRows - 1 && j > 0 && j < output.NumColumns - 1)
{
z1 = ras.Value[i - 1, j - 1];
z2 = ras.Value[i - 1, j];
z3 = ras.Value[i - 1, j + 1];
z4 = ras.Value[i, j - 1];
z5 = ras.Value[i, j + 1];
z6 = ras.Value[i + 1, j - 1];
z7 = ras.Value[i + 1, j];
z8 = ras.Value[i + 1, j + 1];
//3rd Order Finite Difference slope algorithm
dZ_dx = inZFactor * ((z3 - z1) + 2 * (z5 - z4) + (z8 - z6)) / (8 * ras.CellWidth);
dZ_dy = inZFactor * ((z1 - z6) + 2 * (z2 - z7) + (z3 - z8)) / (8 * ras.CellHeight);
slope = Math.Atan(Math.Sqrt((dZ_dx * dZ_dx) + (dZ_dy * dZ_dy))) * (180 / Math.PI);
//change to radious and in persentage
if (slopeInPercent)
slope = (Math.Tan(slope * Math.PI / 180)) * 100;
output.Value[i, j] = slope;
if (cancelProgressHandler.Cancel == true)
return false;
}
else
output.Value[i, j] = output.NoDataValue;
if (cancelProgressHandler.Cancel == true)
return false;
}
}
//output = Temp;
if (output.IsFullyWindowed())
{
output.Save();
return true;
}
else
return false;
}
catch (Exception ex)
{
//throw new SystemException("Error in Slope: ", ex);
throw new SystemException(ex.ToString());
}
}