C#+ArcGIS修改图层名称和别名

您所在的位置:网站首页 shp修改字段名称 C#+ArcGIS修改图层名称和别名

C#+ArcGIS修改图层名称和别名

2023-09-15 04:18| 来源: 网络整理| 查看: 265

据帮助文档:

        Object classes in a Geodatabase can have between one and three names. The name of the object class, which is the same as the name of the table in the DBMS in which the objects in the object class are stored, the alias name which the user can set for display purposes in end user applications. The third name is the model name which is a tool for developers of custom objects to use to guarantee the names of objects independent of the true name or alias name.

代码:以gdb中图层为例修改图层名称(name)和别名(alias name)

public void AlterName() { Type type = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory"); IWorkspaceFactory pWorksapcFactory = (IWorkspaceFactory)Activator.CreateInstance(type); IWorkspace pWorkspace = pWorksapcFactory.OpenFromFile(@"F:\GIS测试数据\测试.gdb", 0); IFeatureWorkspace pFWK = pWorkspace as IFeatureWorkspace; IFeatureClass pFeatureClass = pFWK.OpenFeatureClass("SSS"); //修改图层名称 IDataset dataset = pFeatureClass as IDataset; dataset.Rename("MC"); //修改图层别名 AlterAliasName(pFeatureClass); } /// /// 修改数据集别名 /// /// 对象类 public void AlterAliasName(IObjectClass objectClass) { //cast for the IClassSchemaEdit IClassSchemaEdit pOcSchemaEdit = objectClass as IClassSchemaEdit; //set and exclusive lock on the class 设置并独占锁 ISchemaLock schemaLock = (ISchemaLock)objectClass; schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock); //alter the class extension for the class pOcSchemaEdit.AlterAliasName("修改别名"); //release the exclusive lock 释放锁 schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock); }

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3