在個人地圖軟件TimeGIS中加入了等值線生成的功能:html
等值線的生成使用了wCoutour庫, 代碼根據這裏的例子修改,http://www.06climate.com/view/1244.htmlgit
今天發現 MeteoInfo 氣象軟件開源了:https://github.com/meteoinfo 點贊一下 http://www.meteothinker.com/ github
具體步驟以下:結合wContour例子, 準備了一個帶多邊形的例子 china.shp,準備一些監測點數據函數
//csv格式:
//Stid,Latitude,Lontitude,Temperature
//北京,116.41667,39.91667,-3.2
//上海,121.43333,34.50000,4.9spa
//KsGisContour isoline = new KsGisContour();
//string inputShpFileName = @"C:\KuaiShou\ksgis\shape\china\china.shp"; //polygon格式
//string inputDiscreteCsvFileName = @"c:\KuaiShou\src\Libraries\wContour\Temp_2010101420.csv";
//int interpolateRowCount = 100;
//int interpolateColCount = 100;
//double left = 40; double bottom = 0; double right = 140; double top = 60; //範圍左下右上
//double[] isolineValues = new double[] { -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40 }; //等值線值
//bool ret = isoline.CreateIsoline(inputShpFileName, inputDiscreteCsvFileName,
// interpolateRowCount, interpolateColCount, left, bottom, right, top, isolineValues);3d
在CreateIsoLine()裏面htm
先準備好數據,而後調用一系列函數來生成等值線blog
Interpolate.CreateGridXY_Num(left, bottom, right, top, rows, cols, ref _X, ref _Y); //左下,右上ip
_gridData = new double[rows, cols];
_gridData = Interpolate.Interpolation_IDW_Neighbor(_discreteData, _X, _Y, 8, _undefData);ci
//Contour
//double[] values = new double[] { -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40 };
SetContourValues(isolineValues);
TracingContourLines();
SmoothLines();
ClipLines();
TracingPolygons();
ClipPolygons();
最好再把結果數據保存到shp文件裏面並顯示,整個步驟就完成了。
//等值線生成文件名: inputShpFileName_isoline.shps
www.TimeGIS.com