• ArcEngine加载SDE图层


    private void btnAddLayers_Click(object sender, EventArgs e)
            {
                //载入图层
                pWSF = new SdeWorkspaceFactory();

                IPropertySet pPropertySet = new PropertySet();
                pPropertySet.SetProperty("Server", "DU");
                pPropertySet.SetProperty("Instance", "esri_sde");
                pPropertySet.SetProperty("user", "sde");
                pPropertySet.SetProperty("password", "111");
                pPropertySet.SetProperty("version", "sde.DEFAULT");

                IWorkspace pSdeWorkspace = null;//sde工作空间
                IFeatureWorkspace pFeatureWorkspace = null;//矢量工作空间
                IRasterWorkspaceEx pRasterWorkspace = null;//栅格工作空间,注意必须是//IRasterWorkspaceEx
                try//打开工作空间
                {
                    pSdeWorkspace = pWSF.Open(pPropertySet, 0);
                    pFeatureWorkspace = pSdeWorkspace as IFeatureWorkspace;
                    pRasterWorkspace = pSdeWorkspace as IRasterWorkspaceEx;

                    //加载栅格图层
                    IRasterDataset pRasterDataset = (IRasterDataset)

    pRasterWorkspace.OpenRasterDataset("SDE.YJ");
                    IRasterLayer pLayerBackground = new RasterLayerClass();
                    pLayerBackground.CreateFromDataset(pRasterDataset);
                    mapControlMain.AddLayer(pLayerBackground);
                    mapControlOverView.AddLayer(pLayerBackground);//鹰眼

                    //加载矢量图层
                    IFeatureClass pFCBorderArea = pFeatureWorkspace.OpenFeatureClass

    ("Background");
                    IFeatureLayer pFLBorderArea = new FeatureLayer();
                    pFLBorderArea.FeatureClass = pFCBorderArea;
                    pFLBorderArea.Name = "边界面";
                    ILayer pLayerBorderArea = pFLBorderArea as ILayer;
                    mapControlMain.AddLayer(pLayerBorderArea);

                    IFeatureClass pFCDepartmentsArea =

    pFeatureWorkspace.OpenFeatureClass("DepartmentsArea");
                    IFeatureLayer pFLDepartmentsArea = new FeatureLayer();
                    pFLDepartmentsArea.FeatureClass = pFCDepartmentsArea;
                    pFLDepartmentsArea.Name = "主要单位";
                    ILayer pLayerDepartmentsArea = pFLDepartmentsArea as ILayer;
                    mapControlMain.AddLayer(pLayerDepartmentsArea);

                    IFeatureClass pFCRoads = pFeatureWorkspace.OpenFeatureClass

    ("Roads");
                    IFeatureLayer pFLRoads = new FeatureLayer();
                    pFLRoads.FeatureClass = pFCRoads;
                    pFLRoads.Name = "道路";
                    ILayer pLayerRoads = pFLRoads as ILayer;
                    mapControlMain.AddLayer(pLayerRoads);

                    IFeatureClass pFCWaterarea = pFeatureWorkspace.OpenFeatureClass

    ("Waterarea");
                    IFeatureLayer pFLWaterarea = new FeatureLayer();
                    pFLWaterarea.FeatureClass = pFCWaterarea;
                    pFLWaterarea.Name = "水域";
                    ILayer pLayerWaterarea = pFLWaterarea as ILayer;
                    mapControlMain.AddLayer(pLayerWaterarea);

                    IFeatureClass pFCRivers = pFeatureWorkspace.OpenFeatureClass

    ("Rivers");
                    IFeatureLayer pFLRivers = new FeatureLayer();
                    pFLRivers.FeatureClass = pFCRivers;
                    pFLRivers.Name = "河流";
                    ILayer pLayerRivers = pFLRivers as ILayer;
                    mapControlMain.AddLayer(pLayerRivers);

                    IFeatureClass pFCCurlvets = pFeatureWorkspace.OpenFeatureClass

    ("Curlvets");
                    IFeatureLayer pFLCurlvets = new FeatureLayer();
                    pFLCurlvets.FeatureClass = pFCCurlvets;
                    pFLCurlvets.Name = "涵洞";
                    ILayer pLayerCurlvets = pFLCurlvets as ILayer;
                    mapControlMain.AddLayer(pLayerCurlvets);

                    IFeatureClass pFCPumpingStations =

    pFeatureWorkspace.OpenFeatureClass("PumpingStation");
                    IFeatureLayer pFLPumpingStations = new FeatureLayer();
                    pFLPumpingStations.FeatureClass = pFCPumpingStations;
                    pFLPumpingStations.Name = "泵站";
                    ILayer pLayerPumpingStations = pFLPumpingStations as ILayer;
                    mapControlMain.AddLayer(pLayerPumpingStations);


                    IFeatureClass pFCBorder = pFeatureWorkspace.OpenFeatureClass

    ("Border");
                    IFeatureLayer pFLBorder = new FeatureLayer();
                    pFLBorder.FeatureClass = pFCBorder;
                    pFLBorder.Name = "边界线";
                    ILayer pLayerBorder = pFLBorder as ILayer;
                    mapControlMain.AddLayer(pLayerBorder);
                    mapControlOverView.AddLayer(pLayerBorder);

                    mapControlMain.ActiveView.Refresh();
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
              
            }

  • 相关阅读:
    GAMBIT、ICEM、HYPERMESH耦合面的处理方法
    如何用hypermesh生成包含interface的流体网格
    python求数字位数的方法
    drawPython
    Python入门计划
    书法与篆刻创作结课
    易忽视的Python知识点
    Ubuntu中,wxpython的TextCtrl引发的error:_pixman_log_error
    在Ubuntu15.10中,使用wxPython的webview和JS进行交互
    PyCharm导入tensorflow包
  • 原文地址:https://www.cnblogs.com/suncarry/p/1737323.html
Copyright © 2020-2023  润新知