- 积分
- 56660
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2012-10-23 22:05 编辑
因为有网友问到MICAPS云图(第13类数据)的用法,这里做个讲解。旧版本的MeteoInfo类库会将云图生成ImageLayer,新版本改为RasterLayer,这样可以进行格点计算、投影等。MICAPS云图数据通常是Lambert投影,在添加云图RasterLayer之前要把MapView投影为云图的投影。
代码如下:
- private void TSMI_MICAPS13_Click(object sender, EventArgs e)
- {
- //Create a MeteoDataInfo object
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- //Open GrADS data file
- string aFile = Application.StartupPath + "\\Sample\\cloud_1009271330.000";
- aDataInfo.OpenMICAPSData(aFile);
- //Get GridData
- GridData cloud = aDataInfo.GetGridData("");
- //Create raster layer
- string palFile = Application.StartupPath + "\\Sample\\I-01.pal";
- RasterLayer aLayer = DrawMeteoData.CreateRasterLayer(cloud, "Raster_Cloud", palFile);
- aLayer.ProjInfo = aDataInfo.ProjInfo;
- //Porject mapview
- layersLegend1.ActiveMapFrame.MapView.ProjectLayers(aDataInfo.ProjInfo);
- //Add layer
- layersLegend1.ActiveMapFrame.AddLayer(aLayer);
- layersLegend1.ActiveMapFrame.MoveLayer(aLayer.Handle, 0);
- layersLegend1.Refresh();
- layersLegend1.ActiveMapFrame.MapView.ZoomToExtent(aLayer.Extent);
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.GetTexts()[0];
- aTitle.SetLabelText("MeteoInfo Class Library Demo - MICAPS 13 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();
- }
复制代码
|
|