等高线回放水平偏差计算方法 Python

import arcpy

import os


arcpy.env.overwriteOutput=True


Table=arcpy.env.scratchGDB


a=arcpy.GetParameterAsText(0)


a1=arcpy.GetParameterAsText(1)


b=arcpy.env.scratchGDB+os.path.sep+"Contour_b"

b1=arcpy.env.scratchGDB+os.path.sep+"Contour_b1"

out_table=arcpy.env.scratchGDB+os.path.sep+"out_tb"

# height1

height_ori=arcpy.GetParameterAsText(2)

# height2

height_end=arcpy.GetParameterAsText(3)

# interval

height_interval=arcpy.GetParameterAsText(4)


Table_name=arcpy.GetParameterAsText(5)


Output_Feature_Class = arcpy.env.scratchGDB+os.path.sep+"output"


height1=int(height_ori)

height2=int(height_end)

interval=int(height_interval)


Number=(height2-height1)/interval+1


arcpy.MakeFeatureLayer_management(a,b);

arcpy.MakeFeatureLayer_management(a1,b1);


arcpy.CreateTable_management(Table,Table_name, "", "");

arr=[];

str1=[];

N=height1

i=0

while N<=height2:

    arcpy.SelectLayerByAttribute_management(b, "NEW_SELECTION", "Contour =  "+str(N))

    arcpy.SelectLayerByAttribute_management(b1, "NEW_SELECTION", "Contour =  "+str(N))

    ## Process: Feature To Polygon

    arcpy.FeatureToPolygon_management(b+";"+b1, Output_Feature_Class, "", "ATTRIBUTES", "")

    arcpy.Statistics_analysis(Output_Feature_Class, out_table, "Shape_Area SUM", "")

    cursor=arcpy.da.SearchCursor(out_table,"SUM_Shape_Area")

    row=cursor.next()

    arr.append(row[0])

    N=N+interval

while i<Number:

    arcpy.AddField_management(Table+os.path.sep+Table_name, "Contours_"+str(height1+i*interval), "DOUBLE")

    str1.append("Contours_"+str(height1+i*interval))

    i+=1


cursor1=arcpy.da.InsertCursor(Table+os.path.sep+Table_name,str1)

cursor1.insertRow(arr)



arcpy.Delete_management(Output_Feature_Class)

arcpy.Delete_management(b)

arcpy.Delete_management(b1)

arcpy.Delete_management(out_table)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值