登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2013-1-23 20:29 编辑
有时候原格点数据的分辨率不符合要求,需要改变网格大小,MeteoInfo库中的GridData类有个Regrid方法可以用来做这项工作。首先需要建立一个目标格点(GridData),可以用GridData的构造函数public GridData(double xStart, double xDelt, int xNum, double yStart, double yDelt, int yNum);然后用原GridData的方法:public void Regrid(GridData gridData),里面的参数是新建的GridData。从下面的示例程序中可以看得更明白,将原来4.5 × 4.5度的格点数据插值到2.5 × 2.5度,用的是双线性插值。
- #-------------------------------------------------------- # Author: Yaqiang Wang
- # Date: 2013-1-23
- # Purpose: Regrid grid data - Bilinear interpolation
- # Note: Sample
- #-----------------------------------------------------------
- import clr
- from System.Collections.Generic import *
- clr.AddReference("MeteoInfoC.dll")
- from MeteoInfoC import *
- from MeteoInfoC.Data import *
- from MeteoInfoC.Data.MeteoData import *
- #---- Set directories
- dataDir = "D:\\Temp\\grads\\"
- #---- Average grid data
- mydata = MeteoDataInfo()
- mydata.OpenGrADSData(dataDir + "model.ctl")
- tnum = mydata.GetTimeNumber()
- datagrid = mydata.GetGridData("PS")
- newgrid = GridData(0, 2.5, 146, -90, 2.5, 73)
- datagrid.Regrid(newgrid)
- newgrid.UNDEF = datagrid.UNDEF
- mipy.MeteoDataset.SetDrawType("grid_point")
- alayer = mipy.MeteoDataset.Display(newgrid)
- alayer.LayerName = "Regrid"
- mipy.MapDocument.ActiveMapFrame.UpdateLayerNode(alayer)
- print 'Finished!'
|