<?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 Re: da Insert cursor writing empy geometry in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427204#M33550</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no examples off hand, but &lt;A href="https://community.esri.com/migrated-users/19932"&gt;Darren Wiens&lt;/A&gt;‌ does a lot of cursor work so probably has some examples on hand.&lt;/P&gt;&lt;P&gt;The only reason I suggest, is that you can produce functions (ie def blah( .... ) ) that may do basic search cursor work collecting shapes (for instance) and then a separate insertcursor that does the writing to a new file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for geometry,&amp;nbsp;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/09/01/distance-calculations-using-the-field-calculator"&gt;/blogs/dan_patterson/2016/09/01/distance-calculations-using-the-field-calculator&lt;/A&gt;&amp;nbsp;has some field calculator expressions that can be stripped to get azimuth of 2 point polylines. &amp;nbsp;simply &amp;nbsp;degrees(arctan2(dy,dx)) in pseudocode where dy is difference in y . &amp;nbsp;Do not use for data in decimal degrees, it is a whole different equation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Sep 2016 20:48:27 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-09-27T20:48:27Z</dc:date>
    <item>
      <title>da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427198#M33544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'll preface this by saying I'm pretty weak on cursors but trying to boot camp myself to basic proficiency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to create a simple script that will take a point feature class and create lines from them. These points are the start point of the the line and for sake of demonstration here, the endpoints are defined mathematically from them. Simple 2-point lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;startingPt = "STARTING_POINTS" #point feature layer in MXD&lt;BR /&gt;fields = ['SHAPE@X', 'SHAPE@Y']&lt;BR /&gt;&lt;BR /&gt;point = arcpy.Point()&lt;BR /&gt;array = arcpy.Array()&lt;BR /&gt;&lt;BR /&gt;featureList = []&lt;BR /&gt;insert = arcpy.da.InsertCursor(r"D:\Temp\Lines.shp",['SHAPE@'])&lt;BR /&gt;&lt;BR /&gt;with arcpy.da.SearchCursor(startingPt, fields) as cursor:&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startX = row[0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startY = row[1]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(point)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endX = startX + 660&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endY = startY + 660&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(point)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polyline = arcpy.Polyline(array)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insert = arcpy.da.InsertCursor(r"D:\Temp\Lines.shp",['SHAPE@'])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insert.insertRow([polyline])&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Start: {},{} End: {},{}".format(startX,startY,endX,endY)&lt;BR /&gt;del cursor&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The script successfully writes rows to the target, but the geometry is empty. I'm sure there is a simple (and stupid) mistake in the code. Any help is appreciated and I'm totally open to suggestions. I'd rather not have a copy features or append operation but just an insert unless my logic is totally flawed here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 19:03:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427198#M33544</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2016-09-27T19:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427199#M33545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your code you forgot to build the point . Hopefully that should fix your issue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; for row in cursor:&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startX = row[0]&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startY = row[1]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&amp;nbsp; &lt;SPAN style="color: #ff0000;"&gt;&lt;SPAN class=""&gt;point&lt;/SPAN&gt;&lt;SPAN style="background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN style="background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class=""&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;Point&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;SPAN style="background-color: #f6f6f6;"&gt;startX &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;&lt;SPAN style="background-color: #fafafa;"&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;startY&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(point)&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endX = startX + 660&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endY = startY + 660&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(point)&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polyline = arcpy.Polyline(array)&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insert = arcpy.da.InsertCursor(r"D:\Temp\Lines.shp",['SHAPE@'])&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insert.insertRow([polyline])&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 19:20:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427199#M33545</guid>
      <dc:creator>VikramS</dc:creator>
      <dc:date>2016-09-27T19:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427200#M33546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;plus&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;point &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Point&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;endX &lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; endY&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
array&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;add&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;point&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;otherwise the venture is pointless&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:13:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427200#M33546</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T19:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427201#M33547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! I just stumbled across another post wherein which someone was recalling words from you &lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt;‌ about setting the spatial reference...tried that and it wasn't the issue. I cleaned up the code a bit. Again, I'm totally up to suggestions, but this works!&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;startingPt = "STARTING_POINTS" #point feature layer in MXD&lt;BR /&gt;fields = ['SHAPE@X', 'SHAPE@Y']&lt;BR /&gt;&lt;BR /&gt;#point = arcpy.Point()&lt;BR /&gt;array = arcpy.Array()&lt;BR /&gt;sr = arcpy.Describe(startingPt).spatialReference &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;insert = arcpy.da.InsertCursor(r"D:\Temp\Lines.shp",['SHAPE@'])&lt;BR /&gt;&lt;BR /&gt;with arcpy.da.SearchCursor(startingPt, fields) as cursor:&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startX = row[0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startY = row[1]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endX = startX + 660&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endY = startY + 660&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(arcpy.Point(startX, startY))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(arcpy.Point(endX, endY))&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insert = arcpy.da.InsertCursor(r"D:\Temp\Lines.shp",['SHAPE@'])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polyline = arcpy.Polyline(array,sr)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insert.insertRow([polyline])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.removeAll()&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Start: {},{} End: {},{}".format(startX,startY,endX,endY)&lt;BR /&gt;&lt;BR /&gt;del cursor&lt;BR /&gt;&lt;CODE&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 19:45:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427201#M33547</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2016-09-27T19:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427202#M33548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like that should work, now that you have both the start and end points added to the array, you have enough points to form a 1D line, because it is possible to form a line with 1 point if you aren't careful. &amp;nbsp;The spatial reference is also critical since you will get geometry inaccuracies if not use. &amp;nbsp;&lt;/P&gt;&lt;P&gt;For commentary,&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;bullet-proof your code for python 3.x by changing all print statements to print functions ie. print(stuff goes in here)&lt;/LI&gt;&lt;LI&gt;although permissable, I would suggest collecting all your geometries that you want to create, then open up a new insertcursor outside of the searchcursor and create your geometries as you go along.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Otherwisey you are good-to-go&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 19:54:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427202#M33548</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-09-27T19:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427203#M33549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/Dan_Patterson"&gt;Dan_Patterson&lt;/A&gt;‌ Thanks so much for the suggestions! I'm currently in the process of adding rotation to each line with some basic trig. Regarding your suggestions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I implemented this; was totally unaware of this. Thanks!&lt;/LI&gt;&lt;LI&gt;Are you suggesting I &lt;EM&gt;un-nest &lt;/EM&gt; the two cursors? Again, I'm a real hack here, so if you had an example or reference that would&amp;nbsp; be great. Any harsh words/warnings regarding poor practice of the structure of cursors as they are now?&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 20:12:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427203#M33549</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2016-09-27T20:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427204#M33550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no examples off hand, but &lt;A href="https://community.esri.com/migrated-users/19932"&gt;Darren Wiens&lt;/A&gt;‌ does a lot of cursor work so probably has some examples on hand.&lt;/P&gt;&lt;P&gt;The only reason I suggest, is that you can produce functions (ie def blah( .... ) ) that may do basic search cursor work collecting shapes (for instance) and then a separate insertcursor that does the writing to a new file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for geometry,&amp;nbsp;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/09/01/distance-calculations-using-the-field-calculator"&gt;/blogs/dan_patterson/2016/09/01/distance-calculations-using-the-field-calculator&lt;/A&gt;&amp;nbsp;has some field calculator expressions that can be stripped to get azimuth of 2 point polylines. &amp;nbsp;simply &amp;nbsp;degrees(arctan2(dy,dx)) in pseudocode where dy is difference in y . &amp;nbsp;Do not use for data in decimal degrees, it is a whole different equation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 20:48:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427204#M33550</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-09-27T20:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427205#M33551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You've got two identical lines that create an insert cursor. You only need to create it once - the line before you've created the search cursor. So, you may as well delete the line that re-creates the insert cursor within the search cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as I'm concerned, it's ok to nest an insert cursor within a search or update cursor. I don't know the inner workings, but insert cursors (which run only when called) are quite different from search and update cursors (which loop through all features or those that meet the where clause criteria). You can run into trouble nesting any combination of search or update cursors, especially with large datasets, because it compounds the looping.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 21:50:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427205#M33551</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-09-27T21:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427206#M33552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan, thanks for the insight and what a treasure trove in the article you wrote! Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Sep 2016 12:25:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427206#M33552</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2016-09-28T12:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427207#M33553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Darren, &lt;/P&gt;&lt;P&gt;thanks for picking up on my bonehead move there! Thanks for the additional insight regarding the cursors. Much appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Sep 2016 12:28:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427207#M33553</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2016-09-28T12:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427208#M33554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/17314"&gt;Darren Wiens&lt;/A&gt;‌ &lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;I broke it. No errors. Output FC is getting created but nothing is getting inserted. Previously I was just using an existing FC I made for sake of demonstration. Now I'm want to have the script create the FC. I've also tried using the old temp shape as a template and still not inserting. FWIW, shouldn't be anything to do with the rotation...the coordinates print right etc and I had this working up until I tried to have the cursor insert to a newly created FC.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I explicitly set the existing output shapefile in the insert cursor like:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;#Open Insert Cursor&lt;BR /&gt;insert = arcpy.da.InsertCursor(r"D:\Temp\Lines.shp",['SHAPE@'])&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Then it works.&lt;/P&gt;&lt;P&gt;The current code below fails to write/insert any rows to the target FC. I've also tried to have the input points and output lines exist in different GDBs as a test; this didn't resolve the issue. Curiously, often when trying to open the empty output line FC, ArcMap crashes.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import arcpy, os, sys, math&lt;BR /&gt;from itertools import cycle&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Environment settings&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;outGDB = arcpy.env.scratchGDB&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Local Variables&lt;BR /&gt;#startingPt = arcpy.GetParameterAsText(0)&lt;BR /&gt;#rotation = int(arcpy.GetParameterAsText(1))&lt;BR /&gt;#dist = int(arcpy.GetParameterAsText(2))&lt;BR /&gt;startingPt = "STARTING_POINTS"&lt;BR /&gt;dist = 660&lt;BR /&gt;angles = [0,90,180,270]&lt;BR /&gt;rotation = cycle(angles)&lt;BR /&gt;outName = "crz_lines"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Create target polyline FC&lt;BR /&gt;sr = arcpy.Describe(startingPt).spatialReference&lt;BR /&gt;outLine = arcpy.CreateFeatureclass_management(outGDB,outName,"POLYLINE","","","",sr)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Create an array object&lt;BR /&gt;array = arcpy.Array()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Open Insert Cursor&lt;BR /&gt;insert = arcpy.da.InsertCursor(outLine,['SHAPE@'])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fields = ['SHAPE@X', 'SHAPE@Y']&lt;BR /&gt;with arcpy.da.SearchCursor(startingPt, fields) as cursor:&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set Start points&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startX = row[0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startY = row[1]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Convert rotation values in list from degrees to radians&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rad = math.radians(next(rotation))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Calculate endpoints&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endX= startX + (math.cos(rad) * dist)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endY= startY + (math.sin(rad) * dist)&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Add points to array&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(arcpy.Point(startX, startY))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(arcpy.Point(endX, endY))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Create Polyine object based on the array of points&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polyline = arcpy.Polyline(array,sr)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Insert the feature&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insert.insertRow([polyline])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.removeAll()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ("Start: {},{} End: {},{}".format(startX,startY,endX,endY))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;del cursor&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Sep 2016 15:15:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427208#M33554</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2016-09-28T15:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427209#M33555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;delete the insert at the end as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Sep 2016 15:48:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427209#M33555</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-09-28T15:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427210#M33556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Otherwise the cursor is still open and the insert haven't yet been written or committed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Sep 2016 15:49:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427210#M33556</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-09-28T15:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427211#M33557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Neil, thanks for the response. That doesn't seem to be the issue. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To be clear, if i explicitly set the insert cursor to the existing shapefile, the features are written as expected. If I use the newly created FC in the fGDB, then nothing is written (not even empty geometry).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Sep 2016 15:54:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427211#M33557</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2016-09-28T15:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427212#M33558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Humour me, create a specific fgdb in a location on disk "C:\Temp\MyData.gdb" or something.&lt;/P&gt;&lt;P&gt;Point the create features at that. Make sure you set the environment.workspace variable correctly.&lt;/P&gt;&lt;P&gt;I can't see from your original code where the input points are coming from.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Sep 2016 15:58:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427212#M33558</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-09-28T15:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427213#M33559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/5327"&gt;Neil Ayres&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;Neil you're on to something here. Here are my application level (arcgis desktop) environments:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="235817" alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/235817_environments.PNG" style="width: 620px; height: 80px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Creating an fGDB as recommended and using&lt;/P&gt;&lt;P&gt;outGDB = r"D:\TEMP\test.gdb"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Writes the output as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As mentioned earlier, I also tried to have the input points located (default.gdb) separate from the target lines (scratch.gdb) but that didn't work. Perhaps I have to explicitly set my workspace in the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not understanding why I can't write to the scratchGDB.&lt;/P&gt;&lt;P&gt;If you or anyone suggests I start a new post instead, I'll be glad to.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE:&lt;/P&gt;&lt;P&gt;when I run this as a script tool the cursor inserts to the FC in the scratch GDB as expected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Sep 2016 17:02:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427213#M33559</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2016-09-28T17:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427214#M33560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dont work in that 'Users' space. &amp;nbsp;That area gets bloated... trust me... we ban our students from that area completely&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Sep 2016 22:26:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427214#M33560</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-09-28T22:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: da Insert cursor writing empy geometry</title>
      <link>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427215#M33561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan, &lt;/P&gt;&lt;P&gt;I'll heed that advice. I've become used to relying upon the scratchGDB because the script readily translates into the published environment on our AGS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm still at a loss why it worked as a script tool, but not in the Python console. Oh well! Thanks for everyone's help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2016 11:45:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insert-cursor-writing-empy-geometry/m-p/427215#M33561</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2016-09-29T11:45:02Z</dc:date>
    </item>
  </channel>
</rss>

