<?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: Using Python in ArcGIS 10, create a line between the middle of the lines in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-python-in-arcgis-10-create-a-line-between/m-p/177368#M13643</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is an example on how to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy from arcpy import env env.workspace = r"C:\TEMP\Python\test.gdb" env.overwriteOutput = 1&amp;nbsp; fc1 = "River" fc2 = "New_Poyline"&amp;nbsp; coordList = []&amp;nbsp; arcpy.FeatureVerticesToPoints_management(fc1, "vertices", "MID") arcpy.AddXY_management("vertices") rows = arcpy.SearchCursor("vertices") for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; X = row.getValue("POINT_X") &amp;nbsp;&amp;nbsp;&amp;nbsp; Y = row.getValue("POINT_Y") &amp;nbsp;&amp;nbsp;&amp;nbsp; coordList.append([X, Y])&amp;nbsp; del row, rows&amp;nbsp; coordList.sort()&amp;nbsp; point = arcpy.Point() array = arcpy.Array()&amp;nbsp; for feature in coordList: &amp;nbsp;&amp;nbsp;&amp;nbsp; point.X = feature[0] &amp;nbsp;&amp;nbsp;&amp;nbsp; point.Y = feature[1] &amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(point)&amp;nbsp; polyline = arcpy.Polyline(array) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.removeAll() arcpy.Delete_management("vertices") arcpy.CopyFeatures_management(polyline, fc2)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will create a polyline feature class using the midpoint vertices of each River segment.&amp;nbsp; It starts from the lowest mid-point and ends at the highest.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Feb 2012 16:28:27 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2012-02-22T16:28:27Z</dc:date>
    <item>
      <title>Using Python in ArcGIS 10, create a line between the middle of the lines</title>
      <link>https://community.esri.com/t5/python-questions/using-python-in-arcgis-10-create-a-line-between/m-p/177367#M13642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have got a river network as a feature class in a gdb. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to calculate the topologic attributes via the connectivity graph of the river network. A graph-theoretic representation of river networks uses rivers as vertices and river junctions as links of a connectivity graph to understand the topology of river network (takes rivers as nodes and river intersections as links of a connectivity graph). It will give information about centrality of lines and also simplify the network.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In order to do this, I want to draw lines from the middle of each river branch to the middle of intersected higher order river. By this way, I can calculate the topological centrality of a river branch by using from-to node information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When doing this manually, I draw a polyline from the middle of a river line to the middle of intersected higher order river line. Please help me to do this automatically by using Python in ArcGIS 10. If I do it manually it will take too long because of the drainage density.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]12116[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 12:06:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-in-arcgis-10-create-a-line-between/m-p/177367#M13642</guid>
      <dc:creator>Alper_Sen</dc:creator>
      <dc:date>2012-02-22T12:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python in ArcGIS 10, create a line between the middle of the lines</title>
      <link>https://community.esri.com/t5/python-questions/using-python-in-arcgis-10-create-a-line-between/m-p/177368#M13643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is an example on how to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy from arcpy import env env.workspace = r"C:\TEMP\Python\test.gdb" env.overwriteOutput = 1&amp;nbsp; fc1 = "River" fc2 = "New_Poyline"&amp;nbsp; coordList = []&amp;nbsp; arcpy.FeatureVerticesToPoints_management(fc1, "vertices", "MID") arcpy.AddXY_management("vertices") rows = arcpy.SearchCursor("vertices") for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; X = row.getValue("POINT_X") &amp;nbsp;&amp;nbsp;&amp;nbsp; Y = row.getValue("POINT_Y") &amp;nbsp;&amp;nbsp;&amp;nbsp; coordList.append([X, Y])&amp;nbsp; del row, rows&amp;nbsp; coordList.sort()&amp;nbsp; point = arcpy.Point() array = arcpy.Array()&amp;nbsp; for feature in coordList: &amp;nbsp;&amp;nbsp;&amp;nbsp; point.X = feature[0] &amp;nbsp;&amp;nbsp;&amp;nbsp; point.Y = feature[1] &amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(point)&amp;nbsp; polyline = arcpy.Polyline(array) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.removeAll() arcpy.Delete_management("vertices") arcpy.CopyFeatures_management(polyline, fc2)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will create a polyline feature class using the midpoint vertices of each River segment.&amp;nbsp; It starts from the lowest mid-point and ends at the highest.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 16:28:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-in-arcgis-10-create-a-line-between/m-p/177368#M13643</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-02-22T16:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python in ArcGIS 10, create a line between the middle of the lines</title>
      <link>https://community.esri.com/t5/python-questions/using-python-in-arcgis-10-create-a-line-between/m-p/177369#M13644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much for the answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The points are not in true sequence in the table. Therefore, I add a code part about "select layer by attribute and location management" and use intersections between the rivers to draw lines combining the midpoints of the intersected lines.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But still there is an overwrite problem!&amp;nbsp; Following code copies features by overwriting action. How can i add new features to one feature class or to namely different feature classes and prevent overwriting. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
from arcpy import env
env.workspace = r"D:\pomme de terre 2\pomme de terre2.gdb"
env.overwriteOutput = 1

fc1 = "Flowline24k_sl_u2"
fc2 = "Graph"


for a in range(1,6):

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj = "ID_1=%d" % (a)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management (fc1,"NEW_SELECTION",obj)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(fc1,"INTERSECT",fc1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(fc1,"hidden")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management (fc1,"CLEAR_SELECTION")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coordList = []

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureVerticesToPoints_management("hidden", "vertices", "MID")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddXY_management("vertices")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor("vertices")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X = row.getValue("POINT_X")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Y = row.getValue("POINT_Y")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coordList.append([X, Y])

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del row, rows

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coordList.sort()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point = arcpy.Point()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array = arcpy.Array()


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for feature in coordList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point.X = feature[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point.Y = feature[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(point)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polyline = arcpy.Polyline(array)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.removeAll()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("vertices")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("hidden")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(polyline, fc2)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:07:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-in-arcgis-10-create-a-line-between/m-p/177369#M13644</guid>
      <dc:creator>Alper_Sen</dc:creator>
      <dc:date>2021-12-11T09:07:01Z</dc:date>
    </item>
  </channel>
</rss>

