4 Star 25 Fork 10

Yonghe / GeoFlying

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
TiessenInter.cs 2.42 KB
一键复制 编辑 原始数据 按行查看 历史
Yonghe 提交于 2020-10-02 09:33 . first
using System;
using System.Collections.Generic;
using System.Text;
namespace GeoFly
{
public class TiessenInter:SpatialInterpolate
{
/// <summary>
/// 得到指定日期的栅格图层插值结果
/// </summary>
/// <param name="date">指定的日期</param>
public GridLayer SpatialGridOut(DateTime date)
{
if (this.pStationinfo == null || this.pMeteoData == null)
return null;
//栅格数据结构初始化
m_gridLayer = HydroSimulate.g_GridLayerPara.g_DemLayer.AttributesCopy();
ProgressBar bar = new ProgressBar();
bar.Show();
bar.Text = "正在内插栅格数据";
if (this.m_CoordType == CoordType.UTM_Coord)
{
this.PrepareFromUTM(date);
}
else
{
this.PrepareFromLongLa(date);
}
if (X.Length != Y.Length || X.Length != Z.Length)
throw new Exception("提供的样本数据有误");
for (int row = 0; row < m_gridLayer.rowCount; row++) //开始新一日的空间插值计算
{
for (int col = 0; col < m_gridLayer.colCount; col++)
{
double value = -9999;
//获取当前计算栅格中心坐标
//获取当前计算栅格的坐标
LPoint p = m_gridLayer.CellPosition(row, col);
double CurrentX = p.X;
double CurrentY = p.Y;
double minDist = 1e20;
double minDistValue = 0;
for (int i = 0; i < pStationinfo.Count; i++)
{
double distX = X[i] - CurrentX;
double distY = Y[i] - CurrentY;
double dist = Math.Sqrt(distX * distX + distY * distY);
if (dist < minDist)
{
minDist = dist;
minDistValue = Z[i];
}
}
this.m_gridLayer[row, col] = minDistValue;
}
}
//图层中间过程输出
bar.Close();
return this.m_gridLayer;
}
}
}
C#
1
https://gitee.com/sucksis/geo-flying.git
git@gitee.com:sucksis/geo-flying.git
sucksis
geo-flying
GeoFlying
master

搜索帮助