PointLayer = arcpy。SelectLayerByLocation_management("point","WITHIN_A_DISTANCE",inPolyline,distance,"NEW_SELECTION")
#读取选中的点的坐标
cur = arcpy。da。SearchCursor(PointLayer,"SHAPE@XY")
for row in cur:
x, y = row[0]
print "point",x,y
loc。append([x,y])
print "haha"
del row,cur
#对点要素进行排序
pnt_InOrder = OrderPoint(inPolyline,loc)
#创建输出的线要素类来自优O尔P论R文T网WWw.YoueRw.com 加QQ7520`18766
arcpy。CreateFeatureclass_management(os。path。dirname(outPolyline),os。path。basename(outPolyline),"POLYLINE", inPolyline,'','',inPolyline)
#将坐标写入输出要素类
array = arcpy。Array()
for l in pnt_InOrder:
p = arcpy。Point(l[0],l[1])
print p,"p"
array。add(p)
#array。add(arcpy。Point(EndX,EndY,1))
cur = arcpy。da。InsertCursor(outPolyline, ["SHAPE@"])
cur。insertRow([arcpy。Polyline(array)])
del cur
#给点要素进行排序
def OrderPoint(inPolyline,PointList):
#获取直线的数学方程式,用于排除直线区间外的点
coodlist = []
cur = arcpy。da。SearchCursor(inPolyline,"SHAPE@")
for row in cur:
for part in row[0]:
for pnt in part:
print "Line"
print pnt。X,pnt。Y
coodlist。append([pnt。X,pnt。Y])
del cur,row论文网
startX = coodlist[0][0]
startY = coodlist[0][1]
EndX = coodlist[1][0]
EndY = coodlist[1][1]
print "start",startX,startY
print 'End',EndX,EndY
#算边缘直线斜率,斜距
k = (EndY - startY) / (EndX -startX)
#计算反斜率,
_k = 1 / k
d1 = startY - _k * startX
d2 = EndY - _k * EndX
print d1,d2
#计算反斜率,
_k = 1 / k
#给点集筛选
d_list = []
for pnt in PointList:
pnt_d = pnt[1] - pnt[0] * _k
print pnt_d,"pnt_d"
if( (pnt_d - d1) * (pnt_d - d2) > 0 ):
PointList。remove(pnt)
print "remove"
d_list。append(pnt_d)
#给点排序
d_list。sort()
print d_list
PointList_InOrder = []
for i in range(len(d_list)):
for p in PointList:
if d_list[i] == p[1] - p[0] * _k: