在ArcGis中,我想计算我绘制的道路网络的连通性。因此,根据相互交叉的街道的数量,对各道路交叉口赋予价。然而,在当前情况下,工具箱还将包含两条线(例如以曲线形式),它们以2的价相互连接。我需要删除价格为< 3的列表的所有值,但是因为我几乎没有编程经验,我不知道如何正确地做到这一点。以下是用于计算顶点图层的工具箱中的一段代码。Python:如何从列表中删除价值低于特定值的值
#----------------------------------
#Begin of calculating valence field
gp.addmessage("Begin of calculating valence field")
#----------------------------------
#Make layer of vertices
#----------------------
gp.addmessage("Make layer of vertices")
desc=gp.Describe(inline)
shapefieldname = desc.ShapeFieldName
thesr=desc.SpatialReference
gp.CreateFeatureClass(gp.workspace,vert, "Point","", "ENABLED", "DISABLED", thesr)
gp.addfield(vert, "valence", "short")
listk=[]
rows=gp.SearchCursor(inline)
row = rows.Next()
while row:
feat = row.GetValue(shapefieldname)
partnum=0
partcount=feat.PartCount
print partcount
while partnum < partcount:
part = feat.GetPart(partnum)
pnt = part.Next()
pntcount = 0
thex=pnt.x
they=pnt.y
thekey=(thex*1000000)+they
while pnt:
if thekey not in listk:
cur = gp.InsertCursor(vert)
rowvert = cur.NewRow()
rowvert.shape = pnt
cur.InsertRow(rowvert)
listk.append(thekey)
pnt = part.Next()
pntcount += 1
partnum += 1
row=rows.next()
del row, rows, cur
# Remove all values valence < 3
#-------------------------------
您可能需要阅读[问] – boardrider
这个问题应该被移到http://gis.stackexchange.com/。任何人都可以为移民投票吗? – jotrocken