Hi All,
I have a dbf file with from and to points. I'm trying to use the python examples to generate a polyline but it is defeating me!
The script I have been using is below. Whenever it is run it generates one visible line and creates attribute table entries for the other rows in the input table.
Can anybody suggest what is going wrong?
Cheers, Neil.
Code (the indentation might not be correct on the posting):
import sys, string, os, arcgisscripting
gp = arcgisscripting.create(9.3)
gp.OverWriteOutput = True
Out = r"C:\Test_Out.shp"
In = r"C:\In.dbf"
gp.workspace = os.path.dirname(Out)
gp.CreateFeatureclass(os.path.dirname(Out), os.path.basename(Out), "POLYLINE")
cur = gp.InsertCursor (Out)
Searchrows = gp.SearchCursor(In)
Searchrow = Searchrows.Next()
while Searchrow:
row = cur.NewRow()
LineArray = gp.CreateObject("Array")
pnt = gp.CreateObject ("Point")
pnt.x = Searchrow.GetValue("From_Lon")
pnt.y = Searchrow.GetValue("From_Lat")
LineArray.add(pnt)
pnt.x = Searchrow.GetValue("To_Lon")
pnt.y = Searchrow.GetValue("To_Lat")
LineArray.add(pnt)
print Searchrow.GetValue("To_Lon"), Searchrow.GetValue("To_Lat")
row.shape = LineArray
cur.InsertRow(row)
Searchrow = Searchrows.Next()
del row, cur