- 积分
- 55946
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
讲讲站点数据生成的各种图层,主要包括Station Point(站点)、Station Model(站点填图)、Weather Symbol(天气现象符号)、 Station Vector(站点风场矢量)、Station Shaded(站点数据插值成格点数据再生成等值线填色图层)。
用DrawMeteoData类的一些静态方法来创建各种图层:
Station_Point: DrawMeteoData.CreateSTPointLayer(StationData stationData, LegendScheme aLS, string layerName, string fieldName)
Station_Model: DrawMeteoData.CreateStationModelLayer(double[,] stationModelData, double undefine, LegendScheme aLS, string layerName, bool isSurface)
Weather_Symbol: DrawMeteoData.CreateWeatherSymbolLayer(StationData weatherData, LegendScheme aLS, string LName)
Station_Vector: DrawMeteoData.CreateSTVectorLayer(StationData uData, StationData vData, StationData stData, LegendScheme aLS, bool ifColr, string LName, bool isUV)
就不多说了,大家看代码吧:
- private void TSMI_StationPoint_Click(object sender, EventArgs e)
- {
- //Create a MeteoDataInfo object
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- //Open SYNOP data file
- string aFile = Application.StartupPath + "\\Sample\\12010615.syn";
- string stFile = Application.StartupPath + "\\Sample\\SYNOP_Stations.csv";
- aDataInfo.OpenSYNOPData(aFile, stFile);
- //Get StationData
- StationData visData = aDataInfo.GetStationData("Visibility");
- //Create a legend scheme
- bool hasUndefData = false;
- LegendScheme aLS = LegendManage.CreateLegendSchemeFromStationData(visData, LegendType.GraduatedColor,
- ShapeTypes.Point, ref hasUndefData);
- for (int i = 0; i < aLS.BreakNum; i++)
- ((PointBreak)aLS.breakList[i]).Size = 8;
- //Create a contour layer
- VectorLayer aLayer = DrawMeteoData.CreateSTPointLayer(visData, aLS, "StationPoint_Vis", "Vis");
- //Add layer
- layersLegend1.ActiveMapFrame.AddLayer(aLayer);
- layersLegend1.Refresh();
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.GetTexts()[0];
- aTitle.SetLabelText("MeteoInfo Class Library Demo - Station Point Layer");
- //Add or change the legend in layout
- LayoutLegend aLegend;
- if (mapLayout1.GetLegends().Count > 0)
- aLegend = mapLayout1.GetLegends()[0];
- else
- aLegend = mapLayout1.AddLegend(650, 100);
- aLegend.LegendStyle = LegendStyleEnum.Bar_Vertical;
- aLegend.LegendLayer = aLayer;
- if (tabControl1.SelectedIndex == 1)
- mapLayout1.PaintGraphics();
- }
-
- private void TSMI_StationModel_Click(object sender, EventArgs e)
- {
- //Create a MeteoDataInfo object
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- //Open SYNOP data file
- string aFile = Application.StartupPath + "\\Sample\\12010615.syn";
- string stFile = Application.StartupPath + "\\Sample\\SYNOP_Stations.csv";
- aDataInfo.OpenSYNOPData(aFile, stFile);
- //Create a legend scheme
- LegendScheme aLS = LegendManage.CreateSingleSymbolLegendScheme(ShapeTypes.Point, Color.Blue, 12);
- //Get station model data
- double[,] stationModelData = new double[10, 1];
- Extent aExtent = new Extent();
- stationModelData = aDataInfo.GetStationModelData(ref aExtent);
- VectorLayer aLayer = new VectorLayer(ShapeTypes.Point);
- aLayer = DrawMeteoData.CreateStationModelLayer(stationModelData,
- aDataInfo.UNDEF, aLS, "StationModel", true);
- //Add layer
- layersLegend1.ActiveMapFrame.AddLayer(aLayer);
- layersLegend1.Refresh();
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.GetTexts()[0];
- aTitle.SetLabelText("MeteoInfo Class Library Demo - Station Model Layer");
- }
- private void TSMI_WeatherSymbol_Click(object sender, EventArgs e)
- {
- //Create a MeteoDataInfo object
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- //Open SYNOP data file
- string aFile = Application.StartupPath + "\\Sample\\12010615.syn";
- string stFile = Application.StartupPath + "\\Sample\\SYNOP_Stations.csv";
- aDataInfo.OpenSYNOPData(aFile, stFile);
- //Get StationData
- StationData wData = aDataInfo.GetStationData("Weather");
- //Create a legend scheme
- LegendScheme aLS = LegendManage.CreateSingleSymbolLegendScheme(ShapeTypes.Point, Color.Blue, 15);
- //Create a contour layer
- VectorLayer aLayer = DrawMeteoData.CreateWeatherSymbolLayer(wData, aLS, "Weather");
- //Add layer
- layersLegend1.ActiveMapFrame.AddLayer(aLayer);
- layersLegend1.Refresh();
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.GetTexts()[0];
- aTitle.SetLabelText("MeteoInfo Class Library Demo - Weather Symbol Layer");
- //Add or change the legend in layout
- LayoutLegend aLegend;
- if (mapLayout1.GetLegends().Count > 0)
- aLegend = mapLayout1.GetLegends()[0];
- else
- aLegend = mapLayout1.AddLegend(650, 100);
- aLegend.LegendStyle = LegendStyleEnum.Bar_Vertical;
- aLegend.LegendLayer = aLayer;
- if (tabControl1.SelectedIndex == 1)
- mapLayout1.PaintGraphics();
- }
- private void TSMI_StationVector_Click(object sender, EventArgs e)
- {
- //Create a MeteoDataInfo object
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- //Open SYNOP data file
- string aFile = Application.StartupPath + "\\Sample\\12010615.syn";
- string stFile = Application.StartupPath + "\\Sample\\SYNOP_Stations.csv";
- aDataInfo.OpenSYNOPData(aFile, stFile);
- //Get StationData
- StationData wdData = aDataInfo.GetStationData("WindDirection");
- StationData wsData = aDataInfo.GetStationData("WindSpeed");
- //Create a legend scheme
- LegendScheme aLS = LegendManage.CreateSingleSymbolLegendScheme(ShapeTypes.Point, Color.Blue, 15);
- //Create a contour layer
- VectorLayer aLayer = DrawMeteoData.CreateSTVectorLayer(wdData, wsData, wdData, aLS, false, "StationVector", false);
- //Add layer
- layersLegend1.ActiveMapFrame.AddLayer(aLayer);
- layersLegend1.Refresh();
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.GetTexts()[0];
- aTitle.SetLabelText("MeteoInfo Class Library Demo - Station Wind Vector Layer");
- }
- private void TSMI_StationShaded_Click(object sender, EventArgs e)
- {
- this.Cursor = Cursors.WaitCursor;
- //Read data info
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- string aFile = Application.StartupPath + "\\Sample\\rain_2008072220.csv";
- aDataInfo.OpenLonLatData(aFile);
- //Get station data
- StationData stationData = aDataInfo.GetStationData("Precipitation6h");
- //Interpolate
- GridDataPara aGDP = new GridDataPara();
- aGDP.dataExtent.minX = 60;
- aGDP.dataExtent.maxX = 140;
- aGDP.dataExtent.minY = -20;
- aGDP.dataExtent.maxY = 60;
- aGDP.xNum = 80;
- aGDP.yNum = 80;
- GridInterpolation gridInterp = new GridInterpolation();
- gridInterp.GridDataParaV = aGDP;
- gridInterp.GridInterMethodV = GridInterMethod.IDW_Radius;
- gridInterp.Radius = 2;
- gridInterp.MinPointNum = 1;
- double[] X = new double[1];
- double[] Y = new double[1];
- ContourDraw.CreateGridXY(gridInterp.GridDataParaV, ref X, ref Y);
- double[,] S = stationData.Data;
- S = ContourDraw.FilterDiscreteData_Radius(S, gridInterp.Radius,
- gridInterp.GridDataParaV.dataExtent, stationData.UNDEF);
- GridData gridData = ContourDraw.InterpolateDiscreteData_Radius(S,
- X, Y, gridInterp.MinPointNum, gridInterp.Radius, stationData.UNDEF);
- //Create legend scheme
- bool hasNoData = true;
- LegendScheme aLS = LegendManage.CreateLegendSchemeFromGridData(gridData, LegendType.GraduatedColor,
- ShapeTypes.Polygon, ref hasNoData);
- ((PolygonBreak)aLS.breakList[0]).DrawFill = false;
- //Create layer
- VectorLayer aLayer = new VectorLayer(ShapeTypes.Polygon);
- aLayer = DrawMeteoData.CreateShadedLayer(gridData, aLS, "Rain", "Rain");
- aLayer.IsMaskout = true;
- //Add layer
- layersLegend1.ActiveMapFrame.AddLayer(aLayer);
- layersLegend1.ActiveMapFrame.MoveLayer(aLayer.Handle, 0);
- layersLegend1.Refresh();
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.GetTexts()[0];
- aTitle.SetLabelText("MeteoInfo Class Library Demo - Station Shaded Layer");
- //Add or change the legend in layout
- LayoutLegend aLegend;
- if (mapLayout1.GetLegends().Count > 0)
- aLegend = mapLayout1.GetLegends()[0];
- else
- aLegend = mapLayout1.AddLegend(650, 100);
- aLegend.LegendStyle = LegendStyleEnum.Bar_Vertical;
- aLegend.LegendLayer = aLayer;
- if (tabControl1.SelectedIndex == 1)
- mapLayout1.PaintGraphics();
- this.Cursor = Cursors.Default;
- }
复制代码
运行结果:
|
|