<?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: Creating small polylines from point coordinates in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/creating-small-polylines-from-point-coordinates/m-p/244106#M18963</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have some vague recollection that the spatial reference had to be set otherwise you got errors in geometry creation.&amp;nbsp; I have included a small demo script...you can add to the list of values to calculate for...values are calculated from the origin...just copy and paste the code into a script window...tab spacing is 2 spaces&lt;/P&gt;&lt;P&gt;'''&lt;BR /&gt;import math&lt;BR /&gt;import arcpy&lt;BR /&gt;pnt = arcpy.Point()&lt;/P&gt;&lt;P&gt;polylines = []&lt;BR /&gt;vals = [0.001, 0.1, 10.0, math.sqrt(2.0), 2.0]&lt;BR /&gt;for a_val in vals:&lt;BR /&gt;&amp;nbsp; polylines.append( [[0.0,0.0],[a_val,0.0]] )&amp;nbsp; #positive out&lt;BR /&gt;&amp;nbsp; polylines.append( [[0.0,0.0],[-a_val,0.0]] ) #negative out&lt;BR /&gt;&amp;nbsp; polylines.append( [[a_val,0.0],[0.0,0.0]] )&amp;nbsp; #positive in&lt;BR /&gt;&amp;nbsp; polylines.append( [[-a_val,0.0],[0.0,0.0]] ) #negative in&lt;BR /&gt;array = arcpy.Array()&lt;BR /&gt;polys = []&lt;BR /&gt;for i in range(len(polylines)):&lt;BR /&gt;&amp;nbsp; a_poly = polylines&lt;I&gt;&lt;BR /&gt;&amp;nbsp; print "\n", "Coordinates: ", a_poly&lt;BR /&gt;&amp;nbsp; for pair in a_poly:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.X = pair[0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.Y = pair[1]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print " X: %20.16f&amp;nbsp; Y: %20.16f" % (pnt.X, pnt.Y)&lt;BR /&gt;&amp;nbsp; '''&lt;BR /&gt;&amp;nbsp; add an empty spatial reference when creating the&lt;BR /&gt;&amp;nbsp; geometry to go from low to high precision&lt;BR /&gt;&amp;nbsp; '''&lt;BR /&gt;&amp;nbsp; poly = arcpy.Polyline(array,arcpy.SpatialReference())&lt;BR /&gt;&amp;nbsp; cal_leng = poly.length&lt;BR /&gt;&amp;nbsp; centroidX = poly.centroid.X&lt;BR /&gt;&amp;nbsp; centroidY = poly.centroid.Y&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; print "Polyline properties:"&lt;BR /&gt;&amp;nbsp; print " length:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %20.16f" % (cal_leng)&lt;BR /&gt;&amp;nbsp; print " centroid (x,y: %20.16f, %10.16f" % (centroidX, centroidY)&lt;/P&gt;&lt;P&gt;&amp;nbsp; array.removeAll()&lt;BR /&gt;&amp;nbsp; polys.append(poly)&amp;nbsp; #for further use&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Jul 2014 21:11:38 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2014-07-25T21:11:38Z</dc:date>
    <item>
      <title>Creating small polylines from point coordinates</title>
      <link>https://community.esri.com/t5/python-questions/creating-small-polylines-from-point-coordinates/m-p/244103#M18960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #999999; font-family: Roboto, Arial, sans-serif;"&gt;I am trying to create a polyline geometry from point coordinates using Arcpy (ArcGIS 10.1). I can do that if the length of lines are not short (&amp;gt;100 ft). However, my script creates an empt geometry when I try to create a line of length ~10s of feet. E.g, creating a line for the start points &lt;/SPAN&gt;&lt;SPAN style="color: #999999; font-family: Roboto, Arial, sans-serif;"&gt;(32.297159, -90.211997) and end point &lt;/SPAN&gt;&lt;SPAN style="color: #999999; font-family: Roboto, Arial, sans-serif;"&gt;(32.297179, -90.211997) does not work. I wonder if its a decimal problem or some kind of geometry creation issue. I would appreciate any help!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #999999; font-size: 10pt; font-family: Roboto, Arial, sans-serif;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #999999; font-size: 10pt; font-family: Roboto, Arial, sans-serif;"&gt;sachi&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jul 2014 20:19:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-small-polylines-from-point-coordinates/m-p/244103#M18960</guid>
      <dc:creator>SachidanandaMishra</dc:creator>
      <dc:date>2014-07-25T20:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating small polylines from point coordinates</title>
      <link>https://community.esri.com/t5/python-questions/creating-small-polylines-from-point-coordinates/m-p/244104#M18961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like you are working with decimal degree data and trying to produce a polyline in meters (or feet).&amp;nbsp; I would suggest working with projected coordinates.&amp;nbsp; I would also suggest including your script here so it can be examined for potential script errors&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jul 2014 20:23:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-small-polylines-from-point-coordinates/m-p/244104#M18961</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-07-25T20:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating small polylines from point coordinates</title>
      <link>https://community.esri.com/t5/python-questions/creating-small-polylines-from-point-coordinates/m-p/244105#M18962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;Thanks for your reply. Please see part of my script below that intends to create the line layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#-----------------------------&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;output = "C:\\temp\\line.shp"&lt;/P&gt;&lt;P&gt;createLine = arcpy.CreateFeatureclass_management("in_memory", "createLine", "POLYLINE", "", "DISABLED", "DISABLED", polygon)&lt;/P&gt;&lt;P&gt;cursor = arcpy.da.InsertCursor(createLine, ["SHAPE@"])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Read the coordinates&lt;/P&gt;&lt;P&gt;x1 = -90.211997&lt;/P&gt;&lt;P&gt;y1 = 32.297159&lt;/P&gt;&lt;P&gt;x2 = -90.211997&lt;/P&gt;&lt;P&gt;y2 = 32.297179&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array = arcpy.Array([arcpy.Point(x1, y1), arcpy.Point(x2, y2)])&lt;/P&gt;&lt;P&gt;array_line&amp;nbsp; = arcpy.Polyline(array)&lt;/P&gt;&lt;P&gt;cursor.insertRow((array_line,))&lt;/P&gt;&lt;P&gt;del cursor&lt;/P&gt;&lt;P&gt;arcpy.CopyFeatures_management(createLine, output)&lt;/P&gt;&lt;P&gt;arcpy.Delete_management(createLine)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#-------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jul 2014 20:57:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-small-polylines-from-point-coordinates/m-p/244105#M18962</guid>
      <dc:creator>SachidanandaMishra</dc:creator>
      <dc:date>2014-07-25T20:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Creating small polylines from point coordinates</title>
      <link>https://community.esri.com/t5/python-questions/creating-small-polylines-from-point-coordinates/m-p/244106#M18963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have some vague recollection that the spatial reference had to be set otherwise you got errors in geometry creation.&amp;nbsp; I have included a small demo script...you can add to the list of values to calculate for...values are calculated from the origin...just copy and paste the code into a script window...tab spacing is 2 spaces&lt;/P&gt;&lt;P&gt;'''&lt;BR /&gt;import math&lt;BR /&gt;import arcpy&lt;BR /&gt;pnt = arcpy.Point()&lt;/P&gt;&lt;P&gt;polylines = []&lt;BR /&gt;vals = [0.001, 0.1, 10.0, math.sqrt(2.0), 2.0]&lt;BR /&gt;for a_val in vals:&lt;BR /&gt;&amp;nbsp; polylines.append( [[0.0,0.0],[a_val,0.0]] )&amp;nbsp; #positive out&lt;BR /&gt;&amp;nbsp; polylines.append( [[0.0,0.0],[-a_val,0.0]] ) #negative out&lt;BR /&gt;&amp;nbsp; polylines.append( [[a_val,0.0],[0.0,0.0]] )&amp;nbsp; #positive in&lt;BR /&gt;&amp;nbsp; polylines.append( [[-a_val,0.0],[0.0,0.0]] ) #negative in&lt;BR /&gt;array = arcpy.Array()&lt;BR /&gt;polys = []&lt;BR /&gt;for i in range(len(polylines)):&lt;BR /&gt;&amp;nbsp; a_poly = polylines&lt;I&gt;&lt;BR /&gt;&amp;nbsp; print "\n", "Coordinates: ", a_poly&lt;BR /&gt;&amp;nbsp; for pair in a_poly:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.X = pair[0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.Y = pair[1]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print " X: %20.16f&amp;nbsp; Y: %20.16f" % (pnt.X, pnt.Y)&lt;BR /&gt;&amp;nbsp; '''&lt;BR /&gt;&amp;nbsp; add an empty spatial reference when creating the&lt;BR /&gt;&amp;nbsp; geometry to go from low to high precision&lt;BR /&gt;&amp;nbsp; '''&lt;BR /&gt;&amp;nbsp; poly = arcpy.Polyline(array,arcpy.SpatialReference())&lt;BR /&gt;&amp;nbsp; cal_leng = poly.length&lt;BR /&gt;&amp;nbsp; centroidX = poly.centroid.X&lt;BR /&gt;&amp;nbsp; centroidY = poly.centroid.Y&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; print "Polyline properties:"&lt;BR /&gt;&amp;nbsp; print " length:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %20.16f" % (cal_leng)&lt;BR /&gt;&amp;nbsp; print " centroid (x,y: %20.16f, %10.16f" % (centroidX, centroidY)&lt;/P&gt;&lt;P&gt;&amp;nbsp; array.removeAll()&lt;BR /&gt;&amp;nbsp; polys.append(poly)&amp;nbsp; #for further use&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jul 2014 21:11:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-small-polylines-from-point-coordinates/m-p/244106#M18963</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-07-25T21:11:38Z</dc:date>
    </item>
  </channel>
</rss>

