爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3258|回复: 0

等值线间隔与标注问题详解

[复制链接]

新浪微博达人勋

发表于 2018-11-29 09:03:18 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
  在画数据等值线的时候,发现等值线的间距是不可控制的,通过看了论坛http://bbs.06climate.com/forum.p ... =9928&extra=&page=1,其中发现 里面的CreateColors及添加标注 LayerLabelSet函数都没找到。所以本人的解决办法如下:   1、 public static LegendScheme CreateGraduatedLegendScheme(double[] CValues, Color[] colors, ShapeTypes aST, double min, double max, bool hasNodata, double unDef);通过该函数可以发现第二个参数是一个Color[],虽然找不到CreateColors这个函数,我就人为的去构造一个Color[]数组,
for (int i = 0; i < cNum; i++)
                            {
                                if (isnum == false)
                                {
                                    colors = new Color[cNum];
                                    isnum = true;
                                }

                                colors = Color.FromArgb(255, 0, 0);
                            }
到此第一个问题解决了。

2、添加LayerLabelSet这个函数没有,我的方法通过LabelSet来修改。


            aMeteoDataInfo.OpenLonLatData(path);//打开CSV数据
            aMeteoDataInfo.DimensionSet = PlotDimension.Lat_Lon;//设置为经纬度信息  
            StationData aStationData = new StationData();//创建站点数据变量
            _stationinfo.Add((LonLatStationDataInfo)aMeteoDataInfo.DataInfo);
            aStationData = aMeteoDataInfo.GetStationData( “ps”);//需要读取哪里咧的值
                    GridDataSetting aGDP = _interpolationsetting.GridDataSet;
                    aGDP.DataExtent = aExtent;
                    aGDP.XNum =xmax;//间距
                    aGDP.YNum =ymax;
                    _interpolationsetting.GridDataSet = aGDP;
                    _interpolationsetting.InterpolationMethod = InterpolationMethods.IDW_Radius;
                    _interpolationsetting.Radius =radius;
                    _interpolationsetting.MinPointNum = 0;
                    ContourDraw.CreateGridXY(_interpolationsetting.GridDataSet, ref m_x, ref m_y);//设定X,Y坐标最大值及搜索半径
                GridData aGridData = new GridData();
                double[,] S = aStationData.Data;
                double[] X = new double[0];
                double[] Y = new double[0];
                ContourDraw.CreateGridXY(_interpolationsetting.GridDataSet, ref X, ref Y);               S=ContourDraw.FilterDiscreteData_Radius(S,_interpolationsetting.Radius,_interpolationsetting.GridDataSet.DataExtent,aStationData.UNDEF)               aGridData=ContourDraw.InterpolateDiscreteData_Radius(S,X,Y,_interpolationsetting.MinPointNum,_interpolationsetting.Radius,aStationData.UNDEF);
                            VectorLayer m_layer = new VectorLayer(MeteoInfoC.Shape.ShapeTypes.Polyline);
                            double interval = 3;//等值线间隔
                            double[] cValues = LegendManage.CreateContourValuesInterval(aGridData.GetMinValue(), aGridData.GetMaxValue(), interval);
                            int cNum = Convert.ToInt32((aGridData.GetMaxValue() - aGridData.GetMinValue()) / interval);
                            Color[] colors = null;
                            Boolean isnum = false;
                            for (int i = 0; i < cNum; i++)
                            {
                                if (isnum == false)
                                {
                                    colors = new Color[cNum];
                                    isnum = true;
                                }
                                
                                colors = Color.FromArgb(255, 0, 0);
                            }
LegendScheme aLS=LegendManage.CreateGraduatedLegendScheme(cValues,colors,MeteoInfoC.Shape.ShapeTypes.Polyline,aGridData.GetMinValue(), aGridData.GetMaxValue(), false, -9999);                  
                               m_layer=DrawMeteoData.CreateContourLayer(aGridData,aLS,“ps”,“ps”);
//添加标题
                              m_layer.LabelSet.DrawShadow=false;
                              m_layer.LabelSet.DynamicContourLabel = false;
                                m_layer.LabelSet.AutoDecimal = false;
                                m_layer.LabelSet.DecimalDigits = 0;
                                m_layer.LabelSet.LabelFont = new Font("宋体",10);
                                m_layer.AddLabels();
                                mapLayout1.PaintGraphics();
                                mapLayout1.Refresh();


红字代码是我修改的,有不对之处请多多指教。


密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表