zoukankan      html  css  js  c++  java
  • ArcGIS Python拱形面

    # -*- coding: utf-8 -*-
    #by gisoracle 2021.01.23
    import arcpy
    import math
    #保存数据
    def Save(polygon,rows):
    
        row = rows.newRow()
        #row.setValue(shapefieldname,featureList)
        row.shape=polygon
        rows.insertRow(row)
        del row
    
    x=500000 
    y=0
    r=200.0
    pi=3.1415926
    outFeature=arcpy.GetParameterAsText(0)
    array = arcpy.Array()
    #point = arcpy.Point()
    for i in range(0,180):
        x1=x+r*math.cos(i*pi/180)
        Z=r*math.sin(i*pi/180)
        point = arcpy.Point(x1,y,Z)
    #point.X=x1 #point.Y=y #point.Z=Z arcpy.AddMessage("Z="+str(Z)) array.add(point) y=300 for i in range(180,0,-1): x1=x+r*math.cos(i*pi/180) Z=r*math.sin(i*pi/180) point = arcpy.Point(x1,y,Z) #point.X=x1 #point.Y=y #point.Z=Z array.add(point) arcpy.AddMessage("Z=" + str(Z)) rows = arcpy.InsertCursor(outFeature) polygon = arcpy.Polygon(array,None,True) Save(polygon, rows) polygon = None

     

    # -*- coding: utf-8 -*-
    #by gisoracle 2021.01.23
    import arcpy
    import math
    #保存数据
    def Save(polygon,rows):
    
        row = rows.newRow()
        #row.setValue(shapefieldname,featureList)
        row.shape=polygon
        rows.insertRow(row)
        del row
    
    x=500000 
    y1=0
    r=200.0
    pi=3.1415926
    outFeature=arcpy.GetParameterAsText(0)
    array = arcpy.Array()
    #point = arcpy.Point()
    for i in range(0,181):
        x1=x+r*math.cos(i*pi/180)
        Z=r*math.sin(i*pi/180)
        point = arcpy.Point(x1,y1,Z)
        #point.X=x1
        #point.Y=y
        #point.Z=Z
        #arcpy.AddMessage("Z="+str(Z))
        array.add(point)
    y2=300
    for i in range(180,-1,-1):
        x1=x+r*math.cos(i*pi/180)
        Z=r*math.sin(i*pi/180)
        point = arcpy.Point(x1,y2,Z)
        #point.X=x1
        #point.Y=y
        #point.Z=Z
        array.add(point)
        #arcpy.AddMessage("Z=" + str(Z))
    rows = arcpy.InsertCursor(outFeature)
    polygon = arcpy.Polygon(array,None,True)
    Save(polygon, rows)
    #下面底面
    array.removeAll()
    p1 = arcpy.Point(x-r, y1, 0)
    array.add(p1)
    p1 = arcpy.Point(x+r, y1, 0)
    array.add(p1)
    p1 = arcpy.Point(x+r, y2, 0)
    array.add(p1)
    p1 = arcpy.Point(x-r, y2, 0)
    array.add(p1)
    polygon = arcpy.Polygon(array,None,True)
    Save(polygon, rows)
    #外侧面
    
    array.removeAll()
    for i in range(0,181):
        x1=x+r*math.cos(i*pi/180)
        Z=-r*math.sin(i*pi/180)
        point = arcpy.Point(x1,y1,Z)
        arcpy.AddMessage(u"Z==="+str(Z))
        array.add(point)
    
    for i in range(180,-1,-1):
        x1=x+r*math.cos(i*pi/180)
        Z=-r*math.sin(i*pi/180)
        point = arcpy.Point(x1,y2,Z)
    
        array.add(point)
        arcpy.AddMessage(u"Z===" + str(Z))
    rows = arcpy.InsertCursor(outFeature)
    polygon = arcpy.Polygon(array,None,True)
    Save(polygon, rows)
    
    
    polygon = None

     修改后代码

    # -*- coding: utf-8 -*-
    #by gisoracle 2021.01.23
    import arcpy
    import math
    #保存数据
    def Save(polygon,rows):
    
        row = rows.newRow()
        #row.setValue(shapefieldname,featureList)
        row.shape=polygon
        rows.insertRow(row)
        del row
    
    x=500000 
    y1=500
    r=200.0
    pi=3.1415926
    basicz=500
    outFeature=arcpy.GetParameterAsText(0)
    array = arcpy.Array()
    #point = arcpy.Point()
    for i in range(0,181):
        x1=x+r*math.cos(i*pi/180)
        Z=basicz+r*math.sin(i*pi/180)
        point = arcpy.Point(x1,y1,Z)
        #point.X=x1
        #point.Y=y
        #point.Z=Z
        #arcpy.AddMessage("Z="+str(Z))
        array.add(point)
    y2=800
    for i in range(180,-1,-1):
        x1=x+r*math.cos(i*pi/180)
        Z=basicz+r*math.sin(i*pi/180)
        point = arcpy.Point(x1,y2,Z)
        #point.X=x1
        #point.Y=y
        #point.Z=Z
        array.add(point)
        #arcpy.AddMessage("Z=" + str(Z))
    rows = arcpy.InsertCursor(outFeature)
    polygon = arcpy.Polygon(array,None,True)
    Save(polygon, rows)
    #下面底面
    array.removeAll()
    p1 = arcpy.Point(x-r, y1, basicz)
    array.add(p1)
    p1 = arcpy.Point(x+r, y1, basicz)
    array.add(p1)
    p1 = arcpy.Point(x+r, y2, basicz)
    array.add(p1)
    p1 = arcpy.Point(x-r, y2, basicz)
    array.add(p1)
    polygon = arcpy.Polygon(array,None,True)
    Save(polygon, rows)
    #外侧面
    
    array.removeAll()
    for i in range(0,181):
        x1=x+r*math.cos(i*pi/180)
        Z=basicz+-r*math.sin(i*pi/180)
        point = arcpy.Point(x1,y1,Z)
        arcpy.AddMessage(u"Z==="+str(Z))
        array.add(point)
    
    for i in range(180,-1,-1):
        x1=x+r*math.cos(i*pi/180)
        Z=basicz+-r*math.sin(i*pi/180)
        point = arcpy.Point(x1,y2,Z)
    
        array.add(point)
        arcpy.AddMessage(u"Z===" + str(Z))
    rows = arcpy.InsertCursor(outFeature)
    polygon = arcpy.Polygon(array,None,True)
    Save(polygon, rows)
    
    
    polygon = None
  • 相关阅读:
    prim 堆优化+ kruskal 按秩优化
    poj 2679 Adventurous Driving(SPFA 负环)
    poj 1125 Stockbroker Grapevine (dij优化 0ms)
    codevs 4909 寂寞的堆(写的好丑0.0)
    noi 7221 拯救公主 (状态压缩+bfs)
    codevs2059逃出克隆岛(传送门bfs)
    HUD3336
    poj 3974 Palindrome
    疑难杂症
    正则表达 比较两个浮点数
  • 原文地址:https://www.cnblogs.com/gisoracle/p/14324583.html
Copyright © 2011-2022 走看看