当前位置: 首页 > news >正文

【ArcGIS Pro二次开发】(70):杂七杂八的记录

本文用于记录一些使用频率较高但归类繁杂,非系统性的一些代码。

主要方便自己使用和查阅,随时更新。


1、从GDB数据库中打开【FeatureDataset\FeatureClass\Table】

using Geodatabase gdb = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(gdbPath)));
FeatureDataset featureDataset = gdb.OpenDataset<FeatureDataset>(featureDatasetName);
FeatureClass featureClass = gdb.OpenDataset<FeatureClass>(featureClassName);
Table table = gdb.OpenDataset<Table>(tableName);

2、从GDB数据库中获取【FeatureDatasetDefinition\FeatureClassDefinition\TableDefinition】

// 扩展用法:GetDefinitions<>
FeatureDatasetDefinition featureDatasetDefinition = gdb.GetDefinition<FeatureDatasetDefinition>(featureDatasetName);
FeatureClassDefinition featureClassDefinition = gdb.GetDefinition<FeatureClassDefinition>(featureClassName);
TableDefinition tableDefinition = gdb.GetDefinition<TableDefinition>(tableName);

3、从【FeatureLayer\FeatureClass】中获取【Feature\Row】

using (RowCursor rowCursor = featureLayer.Search())
{while (rowCursor.MoveNext()){using Feature feature2 = rowCursor.Current as Feature;using Row row = rowCursor.Current;}
}

4、Feature转换为Geometry

Geometry geometry1 = feature.GetShape();

5、Geometry转换为Polygon

Polygon polygon1 = geometry as Polygon;

6、设置Feature的几何形状

feature.SetShape(geometry);

7、获取线、面要素的折点、首末点

ReadOnlyPointCollection mapPoints = polygon.Points;
ReadOnlyPointCollection mapPoints2 = polyline.Points;
MapPoint startPoint = mapPoints.First();
MapPoint endPoint = mapPoints.Last();

8、switch用法示例

string featureclass_type = esriGeometryType switch
{esriGeometryType.esriGeometryPoint => "Point",esriGeometryType.esriGeometryPolyline => "Polyline",esriGeometryType.esriGeometryPolygon => "Polygon",_ => "",
};

9、获取活动地图视图中选择框选定的要素【SelectiontSet】

SelectionSet selectedSet = MapView.Active.Map.GetSelection();

10、在MapTool中获取选择的要素【SelectiontSet】

SelectionSet selectedSet2 = MapView.Active.GetFeatures(geometry);

11、从【SelectionSet】中获取【Geometry】

var selectionList = selectedSet.ToDictionary();
Inspector inspector = new Inspector();
foreach (var selection in selectionList)
{MapMember mapMember = selection.Key;List<long> oids = selection.Value;foreach (var oid in oids){inspector.Load(mapMember, oid);Polygon polygon2 = inspector.Shape as Polygon;}
}

12、Geometry的属性

double polygonArea = polygon.Area;  // 面积
Envelope polygonExtent = polygon.Extent;   // 范围
GeometryType geometryType = geometry.GeometryType;  // 要素类型
SpatialReference spatialReference = geometry.SpatialReference;   // 坐标系
int pointCount = polyline.PointCount;    // 折点数
http://www.lryc.cn/news/191624.html

相关文章:

  • 竞赛选题 深度学习 机器视觉 人脸识别系统 - opencv python
  • 【工具】SSH端口转发管理器,专门管理SSH Port Forwarding
  • opencv-phase 函数
  • 44.ES
  • 分权分域有啥内容?
  • 6.Docker搭建RabbitMQ
  • 用 docker 创建 jmeter 容器, 实现性能测试,该如何下手?
  • 4年软件测试,突破不了20K,太卷了。。。
  • 机器人控制算法——两轮差速驱动运动模型
  • Queue简介
  • 被面试官问到分布式ID,别再傻乎乎只会答雪花算法了...
  • 使用Boto3访问AWS S3服务
  • ODrive移植keil(五)—— 开环控制和电流变换
  • 【Java学习之道】日期与时间处理类
  • 信息系统项目管理师第四版学习笔记——高级项目管理
  • MySQL建表操作和用户权限
  • TCP/IP(十一)TCP的连接管理(八)socket网络编程
  • 第五章 图
  • 深度学习实战:用Keras搭建深度学习网络做手写数字识别
  • 算法解析:LeetCode——机器人碰撞和最低票价
  • LeetCode刷题总结 - LeetCode 热题 100 - 持续更新
  • Spring是什么?为什么要使用Spring?
  • 自我监督学习日志
  • 配置CA证书
  • 计算机毕业设计选什么题目好?springboot 高校就业管理系统
  • 上海-华为全联接大会|竹云受邀参加华为云ROMAConnect行业生态联盟成立联合发布会
  • 走进GraalVM
  • spark读取hive表字段,区分大小写问题
  • UE4和C++ 开发-头文件(.h) 和实现文件(.cpp)区别
  • git介绍和安装、(git,github,gitlab,gitee介绍)、git工作流程、git常用命令、git忽略文件