資源簡介
工具針對arcgis界址點編號,十分好用!

代碼片段和文件信息
#?-*-?coding:?cp936?-*-
#一月前的寫的一個小工具,實現按照宗地實現對界址點從左上角開始,按順時針方向進行編號,內環編號
#方向為逆時針。編寫環境為ArcGIS9.3在32位的操作系統上(包括win7?32位)速度還可以,64位要慢
#很多。操作對象位arcmap中加載的宗地面層和界址點層。編號結果寫在TOPRS_JZDH字段中,運行時會創建
#TOPRS_JZDH、TOPRS_BZ兩個文本字段中,建議在非編輯環境下使用該工。
#如有疑問?歡迎發EMAIL至ryx32@126.com
#---------------------------------------------------------------------------
class?Feature_No():
????pass
class?Feature_No_J():
????pass
import?arcgisscripting
import?math
import?cmath
import?time
gp?=?arcgisscripting.create(9.3)
gp.OverWriteOutput?=?1
jctb_shp?=?gp.GetParameterAsText(0)
jzd_shp?=?gp.GetParameterAsText(1)
#tbbh_s?=?long(gp.GetParameterAsText(2))
bh_w?=?long(gp.GetParameterAsText(2))
qz?=?gp.GetParameterAsText(3)
rownum?=?0
tbbh_s?=?1
try:
????gp.Addmessage(“***********************************************“)
????
????gp.AddMessage(“本工具由中測新圖(北京)遙感技術有限責任公司?任延旭編制“)
????gp.AddMessage(“使用前請做好數據備份,工具產生的不良后果請自行承擔!“)
????gp.Addmessage(“***********************************************“)
????result?=?gp.GetCount_management(jctb_shp)
????count?=?int(result.GetOutput(0))
????if?count?!=?1:
????????raise?Feature_No
????desc?=?gp.Describe(jctb_shp)
????
????spatialRef?=?gp.Describe(jctb_shp).spatialReference
????if?len(gp.ListFields(jzd_shp“TOPRS_BZ“))?<=?0?:
????????gp.AddField_management(jzd_shp?“TOPRS_BZ“?“TEXT“?““?““?“5“?““?“NULLABLE“?“NON_REQUIRED“?““)
????if?len(gp.ListFields(jzd_shp“TOPRS_JZDH“))?<=?0?:
????????gp.AddField_management(jzd_shp?“TOPRS_JZDH“?“TEXT“?““?““?“5“?““?“NULLABLE“?“NON_REQUIRED“?““)
????gp.MakeFeaturelayer(jctb_shp“lyr_z“)
????gp.SelectlayerByAttribute_management(jzd_shp?“CLEAR_SELECTION“?““)
????gp.MakeFeaturelayer(jzd_shp“lyr_j“)???
????gp.SelectlayerByLocation_management(“lyr_j“?“INTERSECT“?“lyr_z“?““?“NEW_SELECTION“)
????gp.CalculateField_management(“lyr_j“?“TOPRS_BZ“?“\“N\““?“PYTHON“?““)
????gp.MakeFeaturelayer(“lyr_j““lyr1“)
????
????rows_j?=?gp.SearchCursor(“lyr1“)
????row_j?=?rows_j.next()
????shapefieldname?=?gp.Describe(“lyr_z“).shapeFieldName
????rows?=?gp.SearchCursor(“lyr_z“)
????result_pt?=?gp.GetCount_management(“lyr1“)
????count_pt?=?int(result_pt.GetOutput(0))
????row?=?rows.next()
????feat_1?=?row.GetValue(shapefieldname)
????pt_l?=?feat_1.labelPoint
????extent_jzd?=?feat_1.Extent
????x_min?=?extent_jzd.XMin
????y_max?=?extent_jzd.YMax
????dis_Min?=?0
????x_j?=0
????y_j?=?0
????#gp.AddMessage(“正在計算編號起點位置.......“)
????geom?=?row_j.shape
????pt_j?=?geom.getPart()
????
????dis_Min?=?math.sqrt((pt_j.X?-?x_min)*(pt_j.X?-?x_min)+(pt_j.Y-y_max)*(pt_j.Y-y_max))
????x_j?=?pt_j.X
????y_j?=?pt_j.Y
????rownum?+=?1
????
????row_j?=?rows_j.next()
????gp.SetProgressorLabel(“正在計算編號起點位置.......“)
????
????while?row_j:
????????rownum?+=?1
????????geom?=?row_j.shape
????????pt_j?=?geom.getPart()
????????dis?=?math.sqrt((pt_j.X?-?x_min)*(pt
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????3209??2012-06-20?09:09??tbbh_auto93.py
?????文件??????281068??2012-11-06?15:21??使用說明.pdf
?????文件????????7680??2012-11-05?10:32??界址點編號工具.tbx
?????文件????????6963??2012-11-06?11:52??bh_20120921.py
評論
共有 條評論