• 【arcpy】创建点、线、面(孔洞、环、多部件)要素、要素类


    创建点要素、要素类

    #coding=utf-8
    import arcpy
    
    # 点并非几何类,但通常用于构造几何。PointGeometry是几何。
    point=arcpy.Point(10,10)
    point_Geometry=arcpy.PointGeometry(point)
    
    # 调用创建要素类工具创建一个 点要素类
    point_featureClass=arcpy.CreateFeatureclass_management(r'E:3 codingpy codearcpycreatepoint','point.shp','POINT')
    
    # 使用arcpy.da.InsertCursor类插入新创建的 点要素 到 点要素类
    insertCursor = arcpy.da.InsertCursor(point_featureClass, ['Shape@'])
    insertCursor.insertRow([point_Geometry])
    
    del insertCursor

    创建线要素、要素类

    #coding=utf-8
    import arcpy
    
    points=[[0,0],[0,10],[10,10],[10,0]]
    
    # 组成Path的Array对象
    path=arcpy.Array([arcpy.Point(*p) for p in points])
    
    # 通过path(Array)创建Polyline对象
    line_Geometry=arcpy.Polyline(path)
    
    # 调用创建要素类工具创建一个 线要素类
    polyline_featureClass=arcpy.CreateFeatureclass_management(r'E:3 codingpy codearcpycreatepolyline','polyline.shp','POLYLINE')
    
    # 使用arcpy.da.InsertCursor类插入新创建的 点要素 到 点要素类
    insertCursor = arcpy.da.InsertCursor(polyline_featureClass, ['Shape@'])
    insertCursor.insertRow([line_Geometry])
    
    del insertCursor

    创建简单面要素、要素类

    #coding=utf-8
    import arcpy
    # 环的组成点集合
    points=[[0,0],[0,10],[10,10],[10,0],[0,0]]
    
    # 组成环的Array对象
    ring=arcpy.Array([arcpy.Point(*p) for p in points])
    
    # 创建features列表,用于存放要素,在内存
    features=[]
    # 通过ring(Array)创建Polygon对象
    # 将Polygon要素添加到features列表
    features.append(arcpy.Polygon(ring))
    
    # 调用复制要素工具,将内存中的features列表创建为shapefile
    arcpy.CopyFeatures_management(features, r"E:3 codingpy codearcpycreatepolygonpolygon.shp")

    创建多部件面要素、要素类

    创建一个多环面。

    内环的点可以是逆时针,也可以是顺时针的,在创建面的时候arcpy会自动处理拓扑,创建多环面。

    #coding=utf-8
    import arcpy
    # 3个环的组成点集合
    points1=[[0,0],[0,10],[10,10],[10,0],[0,0]]
    points2=[[2,2],[2,8],[8,8],[8,2],[2,2]]
    points3=[[4,4],[4,6],[6,6],[6,4],[4,4]]
    
    # 3个环的Array对象
    ring1=arcpy.Array([arcpy.Point(*p) for p in points1])
    ring2=arcpy.Array([arcpy.Point(*p) for p in points2])
    ring3=arcpy.Array([arcpy.Point(*p) for p in points3])
    
    # 创建features列表,用于存放要素,在内存
    features=[]
    # 通过Array组成的Array创建Polygon对象
    # 将Polygon要素添加到features列表
    features.append(arcpy.Polygon(arcpy.Array([ring1,ring2,ring3])))
    
    # 调用复制要素工具,将内存中的features列表创建为shapefile
    arcpy.CopyFeatures_management(features, r"E:3 codingpy codearcpycreatepolygonpolygon_multiPart.shp")
  • 相关阅读:
    python基础易错题
    经典案例题2
    经典案例题1
    Http和Https的区别
    爬虫过程中需要注意的问题
    [转]项目规模估计方法介绍
    [转]23种设计模式总结
    [转]分布式session的几种实现方式
    [转]Redis哨兵模式(sentinel)学习总结及部署记录(主从复制、读写分离、主从切换)
    [转]【Linux】Linux 目录结构
  • 原文地址:https://www.cnblogs.com/yzhyingcool/p/14117447.html
Copyright © 2020-2023  润新知