shp转featureclass
来源:互联网 发布:安卓版cf刷枪软件 编辑:程序博客网 时间:2024/06/05 08:40
public void ConvertShapefileToFeatureClass(){ // Create a name object for the source (shapefile) workspace and open it. IWorkspaceName sourceWorkspaceName = new WorkspaceNameClass { WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory", PathName = @"C:\Data\Shapefiles" }; IName sourceWorkspaceIName = (IName)sourceWorkspaceName; IWorkspace sourceWorkspace = (IWorkspace)sourceWorkspaceIName.Open(); // Create a name object for the target (file GDB) workspace and open it. IWorkspaceName targetWorkspaceName = new WorkspaceNameClass { WorkspaceFactoryProgID = "esriDataSourcesGDB.FileGDBWorkspaceFactory", PathName = @"C:\Data\Public.gdb" }; IName targetWorkspaceIName = (IName)targetWorkspaceName; IWorkspace targetWorkspace = (IWorkspace)targetWorkspaceIName.Open(); // Create a name object for the source dataset. IFeatureClassName sourceFeatureClassName = new FeatureClassNameClass(); IDatasetName sourceDatasetName = (IDatasetName)sourceFeatureClassName; sourceDatasetName.Name = "Can_Mjr_Cities"; sourceDatasetName.WorkspaceName = sourceWorkspaceName; // Create a name object for the target dataset. IFeatureClassName targetFeatureClassName = new FeatureClassNameClass(); IDatasetName targetDatasetName = (IDatasetName)targetFeatureClassName; targetDatasetName.Name = "Cities"; targetDatasetName.WorkspaceName = targetWorkspaceName; // Open source feature class to get field definitions. IName sourceName = (IName)sourceFeatureClassName; IFeatureClass sourceFeatureClass = (IFeatureClass)sourceName.Open(); // Create the objects and references necessary for field validation. IFieldChecker fieldChecker = new FieldCheckerClass(); IFields sourceFields = sourceFeatureClass.Fields; IFields targetFields = null; IEnumFieldError enumFieldError = null; // Set the required properties for the IFieldChecker interface. fieldChecker.InputWorkspace = sourceWorkspace; fieldChecker.ValidateWorkspace = targetWorkspace; // Validate the fields and check for errors. fieldChecker.Validate(sourceFields, out enumFieldError, out targetFields); if (enumFieldError != null) { // Handle the errors in a way appropriate to your application. Console.WriteLine("Errors were encountered during field validation."); } // Find the shape field. String shapeFieldName = sourceFeatureClass.ShapeFieldName; int shapeFieldIndex = sourceFeatureClass.FindField(shapeFieldName); IField shapeField = sourceFields.get_Field(shapeFieldIndex); // Get the geometry definition from the shape field and clone it. IGeometryDef geometryDef = shapeField.GeometryDef; IClone geometryDefClone = (IClone)geometryDef; IClone targetGeometryDefClone = geometryDefClone.Clone(); IGeometryDef targetGeometryDef = (IGeometryDef)targetGeometryDefClone; // Cast the IGeometryDef to the IGeometryDefEdit interface. IGeometryDefEdit targetGeometryDefEdit = (IGeometryDefEdit)targetGeometryDef; // Set the IGeometryDefEdit properties. targetGeometryDefEdit.GridCount_2 = 1; targetGeometryDefEdit.set_GridSize(0, 0.75); // Create a query filter to only select cities with a province (PROV) value of 'NS.' IQueryFilter queryFilter = new QueryFilterClass(); queryFilter.WhereClause = "PROV = 'NS'"; queryFilter.SubFields = "Shape, NAME, TERM, Pop1996"; // Create the converter and run the conversion. IFeatureDataConverter featureDataConverter = new FeatureDataConverterClass(); IEnumInvalidObject enumInvalidObject = featureDataConverter.ConvertFeatureClass (sourceFeatureClassName, queryFilter, null, targetFeatureClassName, targetGeometryDef, targetFields, "", 1000, 0); // Check for errors. IInvalidObjectInfo invalidObjectInfo = null; enumInvalidObject.Reset(); while ((invalidObjectInfo = enumInvalidObject.Next()) != null) { // Handle the errors in a way appropriate to the application. Console.WriteLine("Errors occurred for the following feature: {0}", invalidObjectInfo.InvalidObjectID); }}
0 0
- shp转featureclass
- .tab如何转.shp?
- Excel经纬度转Shp
- SHP
- MapGIS完美转shp攻略
- shp属性转CAD注记
- Gdal中SHP转GeoJson
- FeatureLayer,FeatureDataset,FeatureClass,Feature几个概念总结(转)
- 全角转半角,arcgis中处理featureClass数据
- 关于FeatureClass
- MIF格式转SHP格式方法总结
- cad图层dwg,dxf转shp
- .osm文件转.shp的方法
- Gdal关于CAD转SHP格式
- 用QGIS将shp转json
- arcgis之shp文件坐标系互转
- dwg文件转shp,将注记内容写入shp文件的属性中
- FeatureLayer和FeatureClass
- IE文档模式的切换,Quirks模式
- Android开发仿QQ聊天滑动listview
- 一只小蜜蜂...
- 萨基姆SAGEMPCM FMX12数字接入设备
- 黑马程序员——集合(二)
- shp转featureclass
- cocos2d-android开发菜单篇(一)上
- redis常用命令
- 不容易系列之(3)—— LELE的RPG难题
- pyqt资料汇总
- hadoop 性能调优 重要参数设置技巧
- swoole在mac os上的环境配置
- Android获取设备ip地址和Mac地址
- 骨牌铺方格