- 积分
- 97
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-2-1
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2012-2-9 12:24:13
|
显示全部楼层
/// <summary>
/// 由csv/txt监测站点的经纬度数据插值生成Grid文件
/// </summary>
/// <param name="csvFile">csv文件(或者txt)文件,要求2,3,4列依次为经度,纬度,插值数据</param>
private string CsvToGrid(string csvFile)
{
LonLatStationDataInfo aDataInfo = new LonLatStationDataInfo();
aDataInfo.ReadDataInfo(csvFile);
//Get station data
StationData stationData = aDataInfo.GetStationData(0);
//Interpolate
//范围
Extent dataExtent = new Extent(106, 115, 24, 33);
GridDataPara aGDP = new GridDataPara();
aGDP.dataExtent = dataExtent;
//格点数量
aGDP.xNum = 300;
aGDP.yNum = 300;
//迭代半径
List<double> radlist = new List<double>();
radlist.Add(30);
GridInterpolation gridInterp = new GridInterpolation();
gridInterp.GridDataParaV = aGDP;
gridInterp.GridInterMethodV = GridInterMethod.Cressman;
gridInterp.MinPointNum = 1;
gridInterp.RadList = radlist;
gridInterp.UnDefData = 0.001;
double[] X = new double[1];
double[] Y = new double[1];
ContourDraw.CreateGridXY(gridInterp.GridDataParaV, ref X, ref Y);
double[,] S = stationData.Data;
GridData gridData = new GridData();
//Cressman
gridData = ContourDraw.InterpolateDiscreteData_Cressman(S, X, Y, gridInterp.UnDefData, gridInterp.RadList);
//导出.grd文件
string outputGridFile = System.IO.Path.ChangeExtension(csvFile, ".grd");
gridData.SaveAsSurferASCIIFile(outputGridFile);
return outputGridFile;
} |
评分
-
查看全部评分
|