反距离权重插值计算程序



public void ChaZhi()



        {



            int
i,j,k;



            float
[,] WS0; //
原始网格数组           



            float
Kq=2.0f; //
权重指数                    



            int
Wm,Wn; //
设定网格数,Wm为列,Wn为行



            float wgx,wgy;
//
每个网格距离;



            float
z0; //
当前网格计算数值



PointF p0=new
PointF(); //
当前网格中心点



            PointF p1=new
PointF(); //
实测点



            MP1 pt=new
MP1();



            float
zk; //
实测点数值



            float
a1,a2; //
计算z0时的上下部分;



            float
dk,xx,yy; //
计算中间变量





            yy=yl;



            for(i=0;i<Wn;i++)



            {



                xx=xl;



                for(j=0;j<Wm;j++)



                {



                    p0.X=xx+wgx/2;



                    p0.Y=yy+wgy/2;



                    a1=0;



                    a2=0;



                    for(k=0;k<MPS.Count;k++)
//
计算当前网格实测点距离



                    {



                        pt=(MP1)MPS[k];                       



                        p1=toMapPoint(pt);



                        zk=pt.Z;



                        dk=Convert.ToSingle(Math.Pow(DistanceP(p0,p1),Kq));



                        a1+=zk/dk;



                        a2+=1/dk;



                    }



                    z0=a1/a2;



                    WS0[j,i]=z0;



                    xx+=wgx;



                }



                yy+=wgy;



            }        



        }





说明:



1. MP1是一个实测点的类,有CODE(代码)X,Y(坐标),Z(数值)等4个属性;



2. MPS是一个集合,放置实测点。



posted @ 2012-04-26 00:24  zhh  阅读(2872)  评论(0编辑  收藏  举报