<?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: Attach existing line endpoints to existing points in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/attach-existing-line-endpoints-to-existing-points/m-p/1277398#M26818</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Backup your data, this will change the geometries!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use the Field Calculator on the Shape field, switch to Arcade, use this script (change the first line to your point fc name)&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// load your points, define the snap radius
var inlets = FeaturesetByName($datastore, "TestPoints")
var snap_radius = 5

// get the current geometry and create a copy
var geom = Geometry($feature)
var new_geom = Dictionary(Text(geom))

// we want to edit the first and last vertex -&amp;gt; indices 0 and -1
var vertex_indices = [0, -1]

// loop over those indices
for(var v in vertex_indices) {
    var i = vertex_indices[v]
    // get the vertex
    var p = geom.paths[i][i]
    // create a buffer around the vertex
    var p_buffer = Buffer(p, snap_Radius)
    // get the first point that is within the buffer
    var p_snap = First(Intersects(p_buffer, inlets))
    // no point found? -&amp;gt; skip
    if(p_snap == null) { continue }
    // change the vertex coordinates to those of the snap point
    new_geom.paths[i][i][0] = Geometry(p_snap).X
    new_geom.paths[i][i][1] = Geometry(p_snap).Y
//    new_geom.paths[i][i][3] = Geometry(p_snap).Z
}

return Polyline(new_geom)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1681229696972.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67670i178D304CB97E43EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_0-1681229696972.png" alt="JohannesLindner_0-1681229696972.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1681229755707.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67672iEA661153672A61EA/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_1-1681229755707.png" alt="JohannesLindner_1-1681229755707.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Apr 2023 16:16:55 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2023-04-11T16:16:55Z</dc:date>
    <item>
      <title>Attach existing line endpoints to existing points</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/attach-existing-line-endpoints-to-existing-points/m-p/1277354#M26817</link>
      <description>&lt;P&gt;I have stormwater laterals(lines) and inlets(points). I need to connect the laterals endpoints to the inlets. Snap doesn't seem to work as it would move the points to the lines.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 15:31:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/attach-existing-line-endpoints-to-existing-points/m-p/1277354#M26817</guid>
      <dc:creator>ShawnKraft1</dc:creator>
      <dc:date>2023-04-11T15:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Attach existing line endpoints to existing points</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/attach-existing-line-endpoints-to-existing-points/m-p/1277398#M26818</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Backup your data, this will change the geometries!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use the Field Calculator on the Shape field, switch to Arcade, use this script (change the first line to your point fc name)&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// load your points, define the snap radius
var inlets = FeaturesetByName($datastore, "TestPoints")
var snap_radius = 5

// get the current geometry and create a copy
var geom = Geometry($feature)
var new_geom = Dictionary(Text(geom))

// we want to edit the first and last vertex -&amp;gt; indices 0 and -1
var vertex_indices = [0, -1]

// loop over those indices
for(var v in vertex_indices) {
    var i = vertex_indices[v]
    // get the vertex
    var p = geom.paths[i][i]
    // create a buffer around the vertex
    var p_buffer = Buffer(p, snap_Radius)
    // get the first point that is within the buffer
    var p_snap = First(Intersects(p_buffer, inlets))
    // no point found? -&amp;gt; skip
    if(p_snap == null) { continue }
    // change the vertex coordinates to those of the snap point
    new_geom.paths[i][i][0] = Geometry(p_snap).X
    new_geom.paths[i][i][1] = Geometry(p_snap).Y
//    new_geom.paths[i][i][3] = Geometry(p_snap).Z
}

return Polyline(new_geom)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1681229696972.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67670i178D304CB97E43EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_0-1681229696972.png" alt="JohannesLindner_0-1681229696972.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1681229755707.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67672iEA661153672A61EA/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_1-1681229755707.png" alt="JohannesLindner_1-1681229755707.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 16:16:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/attach-existing-line-endpoints-to-existing-points/m-p/1277398#M26818</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-04-11T16:16:55Z</dc:date>
    </item>
  </channel>
</rss>

