日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python封装工具类多个项目使用_【arcpy项目实战】将多个点两两生成的最短路径pyhon代码封装入script中...

發布時間:2023/12/4 python 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python封装工具类多个项目使用_【arcpy项目实战】将多个点两两生成的最短路径pyhon代码封装入script中... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

import os

import arcpy

arcpy.env.workspace=arcpy.GetParameterAsText(0)#選取環境

cost =arcpy.GetParameterAsText(1) #成本柵格

shp=arcpy.GetParameterAsText(2) #選取要素的要素類

out_path=arcpy.GetParameterAsText(3) #命名字段裁剪后輸出目錄

cursor=arcpy.da.SearchCursor(shp,['shape@','class','市'])#shape@代表單個要輸,class是其中一個字段

for shit in cursor:

num=str(shit[1]) #將class編號轉換為字符串

out_name=num+"f.shp"#輸出屬性表中每條要素

#arcpy.CopyFeatures_management(row,"c:\\users\\wolfer\\desktop\\test\\new\\"+out_name)#將生成的要素復制一份

#print shp#輸出要素名

arcpy.Select_analysis(shp,out_path+"\\"+out_name,'"class"=\''+num+ '\'')#利用sql查詢要素中的每一條字段,查詢語句需要專制

other=arcpy.da.SearchCursor(shp,['shape@','class','市'])

for row in other:

if row[1]>shit[1]:

out_name1=str(shit[1])+"f"+str(row[1])+"t.shp"

num1=str(row[1])

arcpy.Select_analysis(shp, out_path+"\\"+out_name1,'CLASS=\''+ num1+ '\'') # 利用sql查詢要素中的每一條字段,查詢語句需要專制

arcpy.CheckOutExtension("spatial")

#本地變量

# Local variables:

julishange = "juli"+shit[1]+"f"+row[1]+"t"

huisushange ="huisu"+shit[1]+"f"+row[1]+"t"

lujingshangge = "lujing"+shit[1]+"f"+row[1]+"t"

alline="alline"

tmp="tmp"

line="line"+str(shit[1])+"f"+str(row[1])+"t"

# Process: 成本回溯鏈接

arcpy.gp.CostBackLink_sa(out_path+"\\"+out_name, cost, huisushange, "", julishange)

# Process: 成本路徑

arcpy.gp.CostPath_sa(out_path+"\\"+out_name1, julishange, huisushange, lujingshangge, "EACH_CELL", "FID")

arcpy.AddField_management(lujingshangge,"cost", "LONG")

cursor = arcpy.da.UpdateCursor(lujingshangge, ["PATHCOST", "cost"])

# For each row, evaluate the WELL_YIELD value (index position

# of 0), and update WELL_CLASS (index position of 1)

for one in cursor:

one[1] =one[0]

# Update the cursor with the updated list

cursor.updateRow(one)

# Process: 柵格轉折線

arcpy.RasterToPolyline_conversion(lujingshangge,line, "ZERO", "0", "SIMPLIFY", "cost")

arcpy.AddField_management(line, "frm", "TEXT")

arcpy.AddField_management(line, "to", "TEXT")

cursor = arcpy.da.UpdateCursor(line, ["frm", "to"])

# For each row, evaluate the WELL_YIELD value (index position

# of 0), and update WELL_CLASS (index position of 1)

for m in cursor:

m[0] = shit[1]

m[1] = row[1]

# Update the cursor with the updated list

cursor.updateRow(m)

arcpy.RasterToPolyline_conversion(lujingshangge,line, "ZERO", "0", "SIMPLIFY", "cost")

if arcpy.Exists(alline) and arcpy.Exists(tmp): #判斷是否為第一次循環

arcpy.Delete_management(tmp)

arcpy.CopyFeatures_management(alline, tmp)

arcpy.Delete_management(alline)

arcpy.Merge_management([line, tmp], alline)

else:

arcpy.CopyFeatures_management(line, tmp)

arcpy.CopyFeatures_management(line, alline)

總結

以上是生活随笔為你收集整理的python封装工具类多个项目使用_【arcpy项目实战】将多个点两两生成的最短路径pyhon代码封装入script中...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。