<?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: CENTER LINE BETWEEN TWO POLYLINES in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/center-line-between-two-polylines/m-p/649679#M7084</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With a bit of Python coding you should be able to do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To create point features from your lines' vertices without an Advanced Licence, you need to iterate the feature parts of each line and write the points to a different feature class.&amp;nbsp; There is an example how to do this here (&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001t000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Read polyline geometry&lt;/A&gt;​) and write to the new feature class with the &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w0000000t000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Insert Cursor&lt;/A&gt;. For your situation where the vertices might be far apart, you probably need to break the line features up into equal length smaller segments - for this you can use the positionAlongLine method (find usage instructions on &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/na/018z00000008000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;this page&lt;/A&gt;) in an iteration to determine how far along the line the point should be.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once you have your segmented feature points for each line (in different feature classes), you can check which two points from each line points feature class are the closest to one another, take the geometric centre of them and create an array of these points to create a line feature again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try this code to create the centre line points:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

# point layers loaded in your dataframe
pnts1 = arcpy.mapping.Layer("line1_pnts")
pnts2 = arcpy.mapping.Layer("line2_pnts")

# create search cursor to iterate through first layer
scur = arcpy.SearchCursor(pnts1)
row = scur.next()

closestPnt = 0
closestPntID = 0
cenPnts = []
ctr=0

while row:&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; shp = row.shape
&amp;nbsp;&amp;nbsp; geom = shp.getPart()
&amp;nbsp;&amp;nbsp; print "Geom1 - " + str(row.FID) + ": " + str(geom.X) + ":" + str(geom.Y)
&amp;nbsp;&amp;nbsp; mindist = 9999
&amp;nbsp;&amp;nbsp; tmpdist = 9999
&amp;nbsp;&amp;nbsp;&amp;nbsp; # search cursor for feature in second line point layer
&amp;nbsp;&amp;nbsp; scur2 = arcpy.SearchCursor(pnts2)
&amp;nbsp;&amp;nbsp; row2 = scur2.next()
&amp;nbsp;&amp;nbsp; geom2X = 0
&amp;nbsp;&amp;nbsp; geom2Y = 0
&amp;nbsp;&amp;nbsp; while row2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shp2 = row2.shape
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geom2 = shp2.getPart()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # check distance between points first and second layer and find closest point
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmpdist = shp.distanceTo(shp2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if tmpdist &amp;lt; mindist:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mindist = tmpdist
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; closestPnt = shp2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; closesPntID = row2.FID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geom2X = geom2.X
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geom2Y = geom2.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row2 = scur2.next()
&amp;nbsp;&amp;nbsp; del scur2
&amp;nbsp;&amp;nbsp; print "Geom2 - " + str(closesPntID) + ": " + str(closestPnt.getPart().X) + ":" + str(closestPnt.getPart().Y)&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; print "Dist: " + str(mindist)
&amp;nbsp;&amp;nbsp; if shp != closestPnt:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # calculate geometric centre of two points closest to each other
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cenX = (geom.X + geom2X) / 2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cenY = (geom.Y + geom2Y) / 2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; midpnt = arcpy.Point(cenX, cenY)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create mid line point
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptGeometry = arcpy.PointGeometry(point)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Mid1 &amp;gt;&amp;gt; " + str(cenX) + ":" + str(cenY)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="line-height: 1.5;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="line-height: 1.5;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # add point to array&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cenPnts.append(midpnt)&amp;nbsp; 
&amp;nbsp;&amp;nbsp; row = scur.next()
&amp;nbsp;&amp;nbsp; ctr += 1
del scur

# write list of points to new point feature class ("cenlinepnts" - create point feature class and load into dataframe) for centre line
inscur = arcpy.InsertCursor("cenlinepnts")
insrow = inscur.newRow()
for p in cenPnts:
&amp;nbsp;&amp;nbsp; insrow.shape = p
&amp;nbsp;&amp;nbsp; inscur.insertRow(insrow)
del inscur&lt;/PRE&gt;&lt;P&gt;There might be more efficient ways, but for this you don't need an Advanced licence.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 03:33:28 GMT</pubDate>
    <dc:creator>FC_Basson</dc:creator>
    <dc:date>2021-12-12T03:33:28Z</dc:date>
    <item>
      <title>CENTER LINE BETWEEN TWO POLYLINES</title>
      <link>https://community.esri.com/t5/mapping-questions/center-line-between-two-polylines/m-p/649678#M7083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does anyone know how to create a centre line between two polylines which are parallel BUT NOT at any points.&lt;/P&gt;&lt;P&gt;I have two cable route which are parallel but sometimes they are not as they have been modify to skip obstacles on the seabed. I need to create a center&amp;nbsp; line between these two polylines.&lt;/P&gt;&lt;P&gt;I do not have arcinfo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Oct 2015 05:59:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/center-line-between-two-polylines/m-p/649678#M7083</guid>
      <dc:creator>francescarusso</dc:creator>
      <dc:date>2015-10-21T05:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: CENTER LINE BETWEEN TWO POLYLINES</title>
      <link>https://community.esri.com/t5/mapping-questions/center-line-between-two-polylines/m-p/649679#M7084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With a bit of Python coding you should be able to do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To create point features from your lines' vertices without an Advanced Licence, you need to iterate the feature parts of each line and write the points to a different feature class.&amp;nbsp; There is an example how to do this here (&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001t000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Read polyline geometry&lt;/A&gt;​) and write to the new feature class with the &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w0000000t000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Insert Cursor&lt;/A&gt;. For your situation where the vertices might be far apart, you probably need to break the line features up into equal length smaller segments - for this you can use the positionAlongLine method (find usage instructions on &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/na/018z00000008000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;this page&lt;/A&gt;) in an iteration to determine how far along the line the point should be.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once you have your segmented feature points for each line (in different feature classes), you can check which two points from each line points feature class are the closest to one another, take the geometric centre of them and create an array of these points to create a line feature again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try this code to create the centre line points:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

# point layers loaded in your dataframe
pnts1 = arcpy.mapping.Layer("line1_pnts")
pnts2 = arcpy.mapping.Layer("line2_pnts")

# create search cursor to iterate through first layer
scur = arcpy.SearchCursor(pnts1)
row = scur.next()

closestPnt = 0
closestPntID = 0
cenPnts = []
ctr=0

while row:&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; shp = row.shape
&amp;nbsp;&amp;nbsp; geom = shp.getPart()
&amp;nbsp;&amp;nbsp; print "Geom1 - " + str(row.FID) + ": " + str(geom.X) + ":" + str(geom.Y)
&amp;nbsp;&amp;nbsp; mindist = 9999
&amp;nbsp;&amp;nbsp; tmpdist = 9999
&amp;nbsp;&amp;nbsp;&amp;nbsp; # search cursor for feature in second line point layer
&amp;nbsp;&amp;nbsp; scur2 = arcpy.SearchCursor(pnts2)
&amp;nbsp;&amp;nbsp; row2 = scur2.next()
&amp;nbsp;&amp;nbsp; geom2X = 0
&amp;nbsp;&amp;nbsp; geom2Y = 0
&amp;nbsp;&amp;nbsp; while row2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shp2 = row2.shape
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geom2 = shp2.getPart()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # check distance between points first and second layer and find closest point
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmpdist = shp.distanceTo(shp2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if tmpdist &amp;lt; mindist:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mindist = tmpdist
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; closestPnt = shp2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; closesPntID = row2.FID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geom2X = geom2.X
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geom2Y = geom2.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row2 = scur2.next()
&amp;nbsp;&amp;nbsp; del scur2
&amp;nbsp;&amp;nbsp; print "Geom2 - " + str(closesPntID) + ": " + str(closestPnt.getPart().X) + ":" + str(closestPnt.getPart().Y)&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; print "Dist: " + str(mindist)
&amp;nbsp;&amp;nbsp; if shp != closestPnt:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # calculate geometric centre of two points closest to each other
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cenX = (geom.X + geom2X) / 2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cenY = (geom.Y + geom2Y) / 2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; midpnt = arcpy.Point(cenX, cenY)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create mid line point
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptGeometry = arcpy.PointGeometry(point)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Mid1 &amp;gt;&amp;gt; " + str(cenX) + ":" + str(cenY)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="line-height: 1.5;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="line-height: 1.5;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # add point to array&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cenPnts.append(midpnt)&amp;nbsp; 
&amp;nbsp;&amp;nbsp; row = scur.next()
&amp;nbsp;&amp;nbsp; ctr += 1
del scur

# write list of points to new point feature class ("cenlinepnts" - create point feature class and load into dataframe) for centre line
inscur = arcpy.InsertCursor("cenlinepnts")
insrow = inscur.newRow()
for p in cenPnts:
&amp;nbsp;&amp;nbsp; insrow.shape = p
&amp;nbsp;&amp;nbsp; inscur.insertRow(insrow)
del inscur&lt;/PRE&gt;&lt;P&gt;There might be more efficient ways, but for this you don't need an Advanced licence.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:33:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/center-line-between-two-polylines/m-p/649679#M7084</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2021-12-12T03:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: CENTER LINE BETWEEN TWO POLYLINES</title>
      <link>https://community.esri.com/t5/mapping-questions/center-line-between-two-polylines/m-p/649680#M7085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for your reply. I will have a look to this solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Francesca&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 09:13:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/center-line-between-two-polylines/m-p/649680#M7085</guid>
      <dc:creator>francescarusso</dc:creator>
      <dc:date>2015-10-28T09:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: CENTER LINE BETWEEN TWO POLYLINES</title>
      <link>https://community.esri.com/t5/mapping-questions/center-line-between-two-polylines/m-p/649681#M7086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another possibility is to use some of the Cartography tools, like &lt;EM&gt;Merge Divided Roads&lt;/EM&gt; or &lt;EM&gt;Collapse Dual LInes to Centerlines&lt;/EM&gt;:&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/EN/HELP/MAIN/10.1/index.html#//00700000000w000000" title="http://resources.arcgis.com/EN/HELP/MAIN/10.1/index.html#//00700000000w000000"&gt;ArcGIS Help 10.1&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/EN/HELP/MAIN/10.1/index.html#/Collapse_Dual_Lines_To_Centerline/00700000000t000000/" title="http://resources.arcgis.com/EN/HELP/MAIN/10.1/index.html#/Collapse_Dual_Lines_To_Centerline/00700000000t000000/"&gt;ArcGIS Help 10.1&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One caution - I would definitely check the output closely, as I found found at times both tools to occasionally produce small areas of bizarre results for no apparent reason.&amp;nbsp; As one example, on a long curve it created a centerline that cut &lt;EM&gt;across&lt;/EM&gt; one of the input curve line segments - a "shortcut" - instead of between the curved segments as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris Donohue, GISP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 14:48:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/center-line-between-two-polylines/m-p/649681#M7086</guid>
      <dc:creator>ChrisDonohue__GISP</dc:creator>
      <dc:date>2015-10-28T14:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: CENTER LINE BETWEEN TWO POLYLINES</title>
      <link>https://community.esri.com/t5/mapping-questions/center-line-between-two-polylines/m-p/649682#M7087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Chris for your reply, but if I understand well this Cartography specific tool is available with the advanced licence which I do not have.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you anyway.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Francesca&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 15:15:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/center-line-between-two-polylines/m-p/649682#M7087</guid>
      <dc:creator>francescarusso</dc:creator>
      <dc:date>2015-10-28T15:15:56Z</dc:date>
    </item>
  </channel>
</rss>

