- 积分
- 1322
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-12-8
- 最后登录
- 1970-1-1
|
发表于 2012-11-16 23:07:53
|
显示全部楼层
本帖最后由 wbriver 于 2012-11-16 23:11 编辑
MeteoInfo 发表于 2012-9-12 14:01
你看看cValues里的值是不是都不在press格点值的范围之外?这样会导致没有等值线被追踪出来,因此aLayer是 ...
王老师您好,最近想做个气象适宜度的图,主要用下面几个县市预报数据来做的,大致分三个等级:适宜、较适宜和不适宜(1、2、3级)。。。
我是模仿Demo里面Station Data→Shaded方法来做的,根据预报,每个站点赋值(如数值:1、2、3),再进行插值显示,如图片所示。。。请教王老师如何在图片右侧显示类似左侧显示的色标(左侧的色标是我自己手动改的),谢谢~
- private void TSMI_StationShaded_Click(object sender, EventArgs e)
- {
- this.Cursor = Cursors.WaitCursor;
- //Read data info
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- string aFile = Application.StartupPath + "\\qx_agr.csv";
- aDataInfo.OpenLonLatData(aFile);
-
- //Get station data
- StationData stationData = aDataInfo.GetStationData("SuitabilityDegree");
- //Interpolate
- GridDataPara aGDP = new GridDataPara();
- aGDP.dataExtent.minX = 118.2;
- aGDP.dataExtent.maxX = 121.5;
- aGDP.dataExtent.minY = 30.35;
- aGDP.dataExtent.maxY = 31.2;
- aGDP.xNum = 100;
- aGDP.yNum = 100;
- 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 hasUndefData = false;
- Color[] colors = new Color[] { Color.FromArgb(255, 0, 205, 252), Color.FromArgb(255, 38, 255, 0), Color.FromArgb(255, 255, 0, 0) };
- double[] cValues = LegendManage.CreateContourValuesInterval(1, 3, 1);
- LegendScheme aLS = LegendManage.CreateGraduatedLegendScheme(cValues, colors, ShapeTypes.Polygon, Math.Round(gridData.GetMinValue()), Math.Round(gridData.GetMaxValue()), hasUndefData, -99999);
- //Create a contour layer
- VectorLayer aLayer = DrawMeteoData.CreateShadedLayer(gridData, aLS, "气象适宜度", null);
- aLayer.IsMaskout = true;//设置IsMaskout属性,设为true即可进行边界剪裁
- aLayer.Expanded = true;
- //Add layer
- layersLegend1.ActiveMapFrame.AddLayer(aLayer);
- layersLegend1.ActiveMapFrame.MoveLayer(aLayer.Handle, 0);
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.GetTexts()[0];
-
- LayoutLegend aLegend;
- if (mapLayout1.GetLegends().Count > 0)
- aLegend = mapLayout1.GetLegends()[0];
- else
- aLegend = mapLayout1.AddLegend(700, 150);
- aLegend.LegendStyle = LegendStyleEnum.Bar_Vertical;
- aLegend.LegendLayer = aLayer;
- if (tabControl1.SelectedIndex == 1)
- mapLayout1.PaintGraphics();
- layersLegend1.Refresh();
- this.Cursor = Cursors.Default;
- }
|
-
|