爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3525|回复: 7

雨量色斑图的问题

[复制链接]

新浪微博达人勋

发表于 2015-1-12 09:39:54 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 scguoxc 于 2015-1-12 09:42 编辑

参考论坛的帖子,自己画的色斑图,但是显示就是不对,并且站点的名称被掩盖了
QQ图片20141223094110.jpg

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-1-12 09:40:23 | 显示全部楼层
源码如下


#region 构造函数

        public Form1()
        {
            InitializeComponent();
        }

        #endregion

        #region 窗体载入

        private void Form1_Load(object sender, EventArgs e)
        {
            Add_FS_County_Line();
            createShare();
            SetMapLayout();
        }

        #endregion

        #region 添加县区界线

        private void Add_FS_County_Line()
        {
            string aFile =  @"F:\资料\shp地图\荆门\荆门地区.shp";
            MapLayer aLayer = MapDataManage.OpenLayer(aFile);
            aLayer.LegendScheme.LegendBreaks[0].Color = Color.Black;
            aLayer.LayerName = "县区";
            aLayer.IsMaskout = false;

            MeteoInfoC.Layer.VectorLayer label = (MeteoInfoC.Layer.VectorLayer)aLayer;
            label.LabelSet.FieldName = "NAME";
            label.AvoidCollision = true;
            label.AddLabels();

            layersLegend1.ActiveMapFrame.AddLayer(aLayer);
            mapView1.ZoomToExtent(mapView1.Extent);
        }
        #endregion

        #region 设置maplayout

        private void SetMapLayout()
        {
            //设置画布尺寸
            mapLayout1.PageBounds = Rectangle.FromLTRB(0, 0, 900, 600);
            mapLayout1.ActiveLayoutMap.Left = 3;
            mapLayout1.ActiveLayoutMap.Top = 3;
            mapLayout1.ActiveLayoutMap.Width = 893;
            mapLayout1.ActiveLayoutMap.Height = 593;


            //设置画布活动区域边界样式
            mapLayout1.ActiveLayoutMap.DrawNeatLine = true;
            mapLayout1.ActiveLayoutMap.NeatLineColor = Color.Black;
            mapLayout1.ActiveLayoutMap.NeatLineSize = 3;

            //加入标题
            mapLayout1.AddText("降水分布图", 250, 45, "黑体", 14);

            //加入图例
            LayoutLegend alegend = mapLayout1.AddLegend(3, 417);
            alegend.Font = new Font("宋体", 10);
            alegend.LegendStyle = LegendStyles.Normal;
            alegend.LegendLayer = layersLegend1.ActiveMapFrame.MapView.Layers[1];
            alegend.DrawNeatLine = true;
            alegend.NeatLineColor = Color.Black;
            alegend.NeatLineSize = 2;

            //加入指北针
            LayoutNorthArrow lna = mapLayout1.AddNorthArrow(820, 40);
            lna.BackColor = Color.White;
            lna.ForeColor = Color.Black;
            lna.Width = 40;
            lna.Height = 60;

            mapLayout1.PaintGraphics();
            mapLayout1.Refresh();
        }

        #endregion

        #region 设置插值格点数据

        private void createShare()
        {
            //设置插值格点数据
            GridDataSetting aGDP = new GridDataSetting();
            Extent ex = new Extent();
            ex.minX = 10;
            ex.minY = 10;
            ex.maxX = 150;
            ex.maxY = 150;
            aGDP.DataExtent = ex;      //加入插值范围
            aGDP.YNum = 150;                         //格点点数
            aGDP.XNum = 150;                         //格点点数

            //插值方法
            InterpolationSetting agrid = new InterpolationSetting();
            agrid.GridDataSet = aGDP;
            agrid.InterpolationMethod = InterpolationMethods.IDW_Radius;
            agrid.Radius = 2;
            agrid.MinPointNum = 1;

            double[] X = new double[1];
            double[] Y = new double[1];
            ContourDraw.CreateGridXY(aGDP, ref X, ref Y);


            VectorLayer alayer = (VectorLayer)layersLegend1.ActiveMapFrame.MapView.Layers[0];
            AttributeTable att = new AttributeTable();
            att = alayer.AttributeTable;
            DataTable dt = att.Table;
            int column = dt.Columns.Count;
            int row = dt.Rows.Count;
            double[,] S = new double[3, row];

            Random rand  = new Random();
            double[] num = new double[2] { 0, 30.8 };

            MeteoInfoC.Layer.VectorLayer label = (MeteoInfoC.Layer.VectorLayer)layersLegend1.ActiveMapFrame.MapView.Layers[0];
            for (int i = 0; i < label.ShapeNum; i++)
            {
                Shape tempshape = label.ShapeList[i];
                S[0, i] = tempshape.Extent.minX;
                S[1, i] = tempshape.Extent.minY;
                S[2, i] = num[rand.Next(0, 2)];
               
            }

            S = ContourDraw.FilterDiscreteData_Radius(S, agrid.Radius, agrid.GridDataSet.DataExtent, -9999.0F);
            GridData grid = new GridData();
            grid = ContourDraw.InterpolateDiscreteData_Radius(S, X, Y, agrid.MinPointNum, agrid.Radius, -9999.0F);

            LegendScheme lgd = new LegendScheme(ShapeTypes.Polygon);
            double min = grid.GetMinValue();
            double max = grid.GetMaxValue();
            lgd.ImportFromXMLFile(AppDomain.CurrentDomain.BaseDirectory + "\\Rain.lgs");
            lgd.MaxValue = max;
            lgd.MinValue = min;

            VectorLayer lineLayer = new VectorLayer(ShapeTypes.Polygon);
            lineLayer = DrawMeteoData.CreateShadedLayer(grid, lgd, "图例(毫米)", "LGD");
            lineLayer.Visible = true;
            lineLayer.IsMaskout = true;
            layersLegend1.ActiveMapFrame.AddLayer(lineLayer);

            //加入掩膜
            MaskOut ma = new MaskOut(mapView1);
            ma.MaskLayer = "县区";
            ma.SetMaskLayer = true;
            mapView1.MaskOut = ma;
            mapView1.PaintLayers();
            layersLegend1.Refresh();
        }

        #endregion
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-1-12 09:42:10 | 显示全部楼层
采用随机数显示雨量,两个雨量值分别是 0和30.8

double[] num = new double[2] { 0, 30.8 };

应该会有白色的区域,但是图上没显示出来

      aGDP.YNum = 150;                         //格点点数
            aGDP.XNum = 150;                         //格点点数、

这两个大小不明白是什么意思
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-1-12 10:43:53 来自手机 | 显示全部楼层
昂。。。。。。。。。。
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2015-1-12 11:59:04 | 显示全部楼层

二次开发Demo程序源代码里有相关的内容,你可以去参考。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-1-12 13:12:55 | 显示全部楼层
         aGDP.YNum = 3000;                         //格点点数
            aGDP.XNum = 3000;                         //格点点数

格点点数变大后图形正常,麻烦问一下老师,格点设置有没有什么参考
QQ图片20141223131341.png

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-1-12 16:14:07 | 显示全部楼层
scguoxc 发表于 2015-1-12 13:12
aGDP.YNum = 3000;                         //格点点数
            aGDP.XNum = 3000;         ...

格点范围比研究区域略大就可以了,分辨率需要自己多调几次,找到相对合适的。各种插值算法都有一些人为需要设定的参数,只要结果和站点分布结果一致就可以了,没有什么定式。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-1-19 17:49:21 | 显示全部楼层
本帖最后由 edwardli 于 2015-1-19 17:51 编辑

                                             学到了。就像grads站点插值的时候,网格越密插出来的效果越好
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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