资源简介
工具针对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
评论
共有 条评论