在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