<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Create a line with attributes based on origin and destination points with Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/create-a-line-with-attributes-based-on-origin-and/m-p/289742#M22448</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to create a line with attributes based on origin and destination points with Python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The source table is like a:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ORIGIN_X, ORIGIN_Y, DEST_X, DEST_Y, ATTRIBUTE_1, ATTRIBUTE_2, ATTRIBUTE_3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have used the code in this article [&lt;/SPAN&gt;&lt;A href="http://support.esri.com/en/knowledgebase/techarticles/detail/31879"&gt;http://support.esri.com/en/knowledgebase/techarticles/detail/31879&lt;/A&gt;&lt;SPAN&gt;] to create the lines, but i can't put the attributes in the shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;import sys, string, os, arcgisscripting&lt;BR /&gt;&lt;BR /&gt;gp = arcgisscripting.create()&lt;BR /&gt;&lt;BR /&gt;gp.Overwriteoutput = 1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Specify the location for the new shapefile.&lt;BR /&gt;&lt;BR /&gt;gp.CreateFeatureclass("C:/temp/", "test_line.shp", "POLYLINE")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Define Coordinate System&lt;BR /&gt;&lt;BR /&gt;gp.workspace = "C:/temp/"&lt;BR /&gt;&lt;BR /&gt;gp.toolbox = "management"&lt;BR /&gt;&lt;BR /&gt;coordsys = "Coordinate Systems/Geographic Coordinate Systems/North America/North American Datum 1983.prj"&lt;BR /&gt;&lt;BR /&gt;gp.defineprojection("test_line.shp", coordsys)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Open a cursor to insert rows into the shapefile.&lt;BR /&gt;&lt;BR /&gt;cur = gp.InsertCursor("C:/temp/test_line.shp")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Create an Array and Point object.&lt;BR /&gt;&lt;BR /&gt;lineArray = gp.CreateObject("Array")&lt;BR /&gt;&lt;BR /&gt;pnt = gp.CreateObject("Point")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Open a cursor on the table of XY coordinates to read from. &lt;BR /&gt;&lt;BR /&gt;rows = gp.SearchCursor("c:/pythonTest.dbf")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Reset the cursor to the top.&lt;BR /&gt;&lt;BR /&gt;row = rows.Next()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Loop through each record in the XY table..&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while row:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set the X and Y coordinates for origin vertex.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.x = row.GetValue("Origin_x")&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.y = row.GetValue("Origin_y")&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Insert it into the line array&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lineArray.add(pnt)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set the X and Y coordinates for destination vertex&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.x = row.GetValue("dest_x")&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.y = row.GetValue("dest_y")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Insert it into the line array&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lineArray.add(pnt)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Go to next row in table.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.Next()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Insert the new poly into the feature class.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = cur.NewRow()&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.shape = lineArray&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.InsertRow(feat)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lineArray.RemoveAll()&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;del cur, row, rows&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Sep 2011 19:15:25 GMT</pubDate>
    <dc:creator>RenatoSilveira_Borges</dc:creator>
    <dc:date>2011-09-26T19:15:25Z</dc:date>
    <item>
      <title>Create a line with attributes based on origin and destination points with Python</title>
      <link>https://community.esri.com/t5/python-questions/create-a-line-with-attributes-based-on-origin-and/m-p/289742#M22448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to create a line with attributes based on origin and destination points with Python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The source table is like a:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ORIGIN_X, ORIGIN_Y, DEST_X, DEST_Y, ATTRIBUTE_1, ATTRIBUTE_2, ATTRIBUTE_3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have used the code in this article [&lt;/SPAN&gt;&lt;A href="http://support.esri.com/en/knowledgebase/techarticles/detail/31879"&gt;http://support.esri.com/en/knowledgebase/techarticles/detail/31879&lt;/A&gt;&lt;SPAN&gt;] to create the lines, but i can't put the attributes in the shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;import sys, string, os, arcgisscripting&lt;BR /&gt;&lt;BR /&gt;gp = arcgisscripting.create()&lt;BR /&gt;&lt;BR /&gt;gp.Overwriteoutput = 1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Specify the location for the new shapefile.&lt;BR /&gt;&lt;BR /&gt;gp.CreateFeatureclass("C:/temp/", "test_line.shp", "POLYLINE")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Define Coordinate System&lt;BR /&gt;&lt;BR /&gt;gp.workspace = "C:/temp/"&lt;BR /&gt;&lt;BR /&gt;gp.toolbox = "management"&lt;BR /&gt;&lt;BR /&gt;coordsys = "Coordinate Systems/Geographic Coordinate Systems/North America/North American Datum 1983.prj"&lt;BR /&gt;&lt;BR /&gt;gp.defineprojection("test_line.shp", coordsys)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Open a cursor to insert rows into the shapefile.&lt;BR /&gt;&lt;BR /&gt;cur = gp.InsertCursor("C:/temp/test_line.shp")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Create an Array and Point object.&lt;BR /&gt;&lt;BR /&gt;lineArray = gp.CreateObject("Array")&lt;BR /&gt;&lt;BR /&gt;pnt = gp.CreateObject("Point")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Open a cursor on the table of XY coordinates to read from. &lt;BR /&gt;&lt;BR /&gt;rows = gp.SearchCursor("c:/pythonTest.dbf")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Reset the cursor to the top.&lt;BR /&gt;&lt;BR /&gt;row = rows.Next()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Loop through each record in the XY table..&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while row:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set the X and Y coordinates for origin vertex.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.x = row.GetValue("Origin_x")&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.y = row.GetValue("Origin_y")&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Insert it into the line array&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lineArray.add(pnt)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set the X and Y coordinates for destination vertex&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.x = row.GetValue("dest_x")&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.y = row.GetValue("dest_y")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Insert it into the line array&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lineArray.add(pnt)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Go to next row in table.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.Next()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Insert the new poly into the feature class.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = cur.NewRow()&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.shape = lineArray&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.InsertRow(feat)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lineArray.RemoveAll()&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;del cur, row, rows&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2011 19:15:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-line-with-attributes-based-on-origin-and/m-p/289742#M22448</guid>
      <dc:creator>RenatoSilveira_Borges</dc:creator>
      <dc:date>2011-09-26T19:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create a line with attributes based on origin and destination points with Python</title>
      <link>https://community.esri.com/t5/python-questions/create-a-line-with-attributes-based-on-origin-and/m-p/289743#M22449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No one? Help, please!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Sep 2011 17:13:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-line-with-attributes-based-on-origin-and/m-p/289743#M22449</guid>
      <dc:creator>RenatoSilveira_Borges</dc:creator>
      <dc:date>2011-09-30T17:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a line with attributes based on origin and destination points with Python</title>
      <link>https://community.esri.com/t5/python-questions/create-a-line-with-attributes-based-on-origin-and/m-p/289744#M22450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It looks like you are almost there. All you need to do is create the attribute fields you wish to populate in your output dataset. You do this by using the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;AddField&lt;/SPAN&gt;&lt;SPAN&gt; tool and do that after you have called the createfeatureclass tool. You already have the code to extract data from your input file so you simply extract your attributes and write these to your new output row which you are calling &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;feat&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you can't work out how to do that then upload a sample of your input file so people can see what fields you are wanting to pass to your output dataset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Oct 2011 14:31:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-line-with-attributes-based-on-origin-and/m-p/289744#M22450</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2011-10-10T14:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create a line with attributes based on origin and destination points with Python</title>
      <link>https://community.esri.com/t5/python-questions/create-a-line-with-attributes-based-on-origin-and/m-p/289745#M22451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;At 10.0 there is a tool to turn a table into points and another to turn points into lines.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To save some coding.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 03:37:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-line-with-attributes-based-on-origin-and/m-p/289745#M22451</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2011-10-11T03:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create a line with attributes based on origin and destination points with Python</title>
      <link>https://community.esri.com/t5/python-questions/create-a-line-with-attributes-based-on-origin-and/m-p/289746#M22452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a script that works using &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.SetValue("y",pnt.y)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.UpdateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;y field must exists before like Hornbydd said&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Olivier&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2011 16:13:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-line-with-attributes-based-on-origin-and/m-p/289746#M22452</guid>
      <dc:creator>OlivierOlivier</dc:creator>
      <dc:date>2011-10-25T16:13:20Z</dc:date>
    </item>
  </channel>
</rss>

