码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 【ArcGIS Pro二次开发】(70):杂七杂八的记录


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

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


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

    1. using Geodatabase gdb = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(gdbPath)));
    2. FeatureDataset featureDataset = gdb.OpenDataset(featureDatasetName);
    3. FeatureClass featureClass = gdb.OpenDataset(featureClassName);
    4. Table table = gdb.OpenDataset(tableName);

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

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

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

      1. using (RowCursor rowCursor = featureLayer.Search())
      2. {
      3. while (rowCursor.MoveNext())
      4. {
      5. using Feature feature2 = rowCursor.Current as Feature;
      6. using Row row = rowCursor.Current;
      7. }
      8. }

      4、Feature转换为Geometry

      Geometry geometry1 = feature.GetShape();

      5、Geometry转换为Polygon

      Polygon polygon1 = geometry as Polygon;

      6、设置Feature的几何形状

      feature.SetShape(geometry);

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

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

      8、switch用法示例

      1. string featureclass_type = esriGeometryType switch
      2. {
      3. esriGeometryType.esriGeometryPoint => "Point",
      4. esriGeometryType.esriGeometryPolyline => "Polyline",
      5. esriGeometryType.esriGeometryPolygon => "Polygon",
      6. _ => "",
      7. };

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

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

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

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

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

      1. var selectionList = selectedSet.ToDictionary();
      2. Inspector inspector = new Inspector();
      3. foreach (var selection in selectionList)
      4. {
      5. MapMember mapMember = selection.Key;
      6. List<long> oids = selection.Value;
      7. foreach (var oid in oids)
      8. {
      9. inspector.Load(mapMember, oid);
      10. Polygon polygon2 = inspector.Shape as Polygon;
      11. }
      12. }

      12、Geometry的属性

      1. double polygonArea = polygon.Area; // 面积
      2. Envelope polygonExtent = polygon.Extent; // 范围
      3. GeometryType geometryType = geometry.GeometryType; // 要素类型
      4. SpatialReference spatialReference = geometry.SpatialReference; // 坐标系
      5. int pointCount = polyline.PointCount; // 折点数
    5. 相关阅读:
      启动hadoop并测试问题合集
      SpringBoot学习笔记(4)——B站动力节点
      kubernetes 之 Pod 控制器 Deployment
      C# - 委托、事件、Action、Func
      vue中$attrs,$props,$listener
      【Android development】系列_01创建安卓应用程序
      SmartNews 基于 Flink 的 Iceberg 实时数据湖实践
      深入理解mvcc机制(详解)
      动态规划总结篇!
      Linux执行jps命令的时候报错:-bash: jps: command not found
    6. 原文地址:https://blog.csdn.net/xcc34452366/article/details/133753165
      • 最新文章
      • 攻防演习之三天拿下官网站群
        数据安全治理学习——前期安全规划和安全管理体系建设
        企业安全 | 企业内一次钓鱼演练准备过程
        内网渗透测试 | Kerberos协议及其部分攻击手法
        0day的产生 | 不懂代码的"代码审计"
        安装scrcpy-client模块av模块异常,环境问题解决方案
        leetcode hot100【LeetCode 279. 完全平方数】java实现
        OpenWrt下安装Mosquitto
        AnatoMask论文汇总
        【AI日记】24.11.01 LangChain、openai api和github copilot
      • 热门文章
      • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
        奉劝各位学弟学妹们,该打造你的技术影响力了!
        五年了,我在 CSDN 的两个一百万。
        Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
        面试官都震惊,你这网络基础可以啊!
        你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
        心情不好的时候,用 Python 画棵樱花树送给自己吧
        通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
        13 万字 C 语言从入门到精通保姆级教程2021 年版
        10行代码集2000张美女图,Python爬虫120例,再上征途
      Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
      正则表达式工具 cron表达式工具 密码生成工具

      京公网安备 11010502049817号