<?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 Code for Field Calculation in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/using-code-for-field-calculation/m-p/1495662#M84816</link>
    <description>&lt;P&gt;Caveat, I used ChatGPT to write this Arcade expression based upon the statement - "&lt;SPAN&gt;Write an arcade expression that calculates a field called Drop_Length_Total in a layer called DoubleD where if a line layer called DTTERM touches a point layer called VSP, I'd like the shape_length of the DTTERM layer to be added to the shape_length of a layer called DTTAP that also intersects the same VSP point."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The script completed is as follows - haven't tested it as I don't have the same data as you:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;// Initialize the total drop length variable&lt;BR /&gt;var dropLengthTotal = 0;&lt;/P&gt;&lt;P&gt;// Access the DTTERM layer&lt;BR /&gt;var dttermLayer = FeatureSetByName($map, "DTTERM");&lt;/P&gt;&lt;P&gt;// Access the DTTAP layer&lt;BR /&gt;var dttapLayer = FeatureSetByName($map, "DTTAP");&lt;/P&gt;&lt;P&gt;// Access the VSP points layer&lt;BR /&gt;var vspLayer = FeatureSetByName($map, "VSP");&lt;/P&gt;&lt;P&gt;// Loop through each VSP point&lt;BR /&gt;for (var vspPoint in vspLayer) {&lt;BR /&gt;// Find DTTERM lines that touch the current VSP point&lt;BR /&gt;var touchingDTTERM = Intersects(dttermLayer, vspPoint);&lt;BR /&gt;&lt;BR /&gt;// Find DTTAP lines that intersect the same VSP point&lt;BR /&gt;var intersectingDTTAP = Intersects(dttapLayer, vspPoint);&lt;BR /&gt;&lt;BR /&gt;// Initialize variables to hold lengths&lt;BR /&gt;var dttermLength = 0;&lt;BR /&gt;var dttapLength = 0;&lt;BR /&gt;&lt;BR /&gt;// Sum the lengths of touching DTTERM lines&lt;BR /&gt;for (var line in touchingDTTERM) {&lt;BR /&gt;dttermLength += line.shape_length;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;// Sum the lengths of intersecting DTTAP lines&lt;BR /&gt;for (var line in intersectingDTTAP) {&lt;BR /&gt;dttapLength += line.shape_length;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;// Sum the lengths for the current VSP point&lt;BR /&gt;var totalLengthForVSP = dttermLength + dttapLength;&lt;BR /&gt;&lt;BR /&gt;// Add to the total drop length&lt;BR /&gt;dropLengthTotal += totalLengthForVSP;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Return the total drop length&lt;BR /&gt;return dropLengthTotal;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jun 2024 20:59:09 GMT</pubDate>
    <dc:creator>Robert_LeClair</dc:creator>
    <dc:date>2024-06-20T20:59:09Z</dc:date>
    <item>
      <title>Using Code for Field Calculation</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-code-for-field-calculation/m-p/1492012#M84552</link>
      <description>&lt;P&gt;Hi ESRI Community,&lt;/P&gt;&lt;P&gt;I am working on a project where I need to populate a new field, named Drop_Length_Total, in my layer named "DoubleD". Using calculate field, I've tried to write code to sum the shape_lengths of two lines, but am running into issues. The workflow i'm trying to achieve is below:&lt;/P&gt;&lt;P&gt;If the pink line touches the orange dot, i'd like the shape_length of the pink line to be added to the shape_length of the blue line that also instersects the orange dot. in the end I'd like for these sums to be written to the Drop_Length_Total field in my DoubleD layer. I've included a visual of what would need to be added together below, with the yellow being one summation and the green being another. If anyone has any ideas as to how I can better achieve this workflow, or any code I could test to calculate the field, it would be greatly appreciated. Thank you for any help!&lt;/P&gt;&lt;P&gt;pink lines = DTTERM layer&lt;/P&gt;&lt;P&gt;Orange dots = VSP layer&lt;/P&gt;&lt;P&gt;blue lines = DTTAP layer&lt;/P&gt;&lt;P&gt;blue dots = taps layer&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emoreno_0-1718305053694.png" style="width: 163px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/107006i45A1A7D736A0A671/image-dimensions/163x276?v=v2" width="163" height="276" role="button" title="emoreno_0-1718305053694.png" alt="emoreno_0-1718305053694.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emoreno_1-1718305188539.png" style="width: 154px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/107007i7D0BF52649243A81/image-dimensions/154x262?v=v2" width="154" height="262" role="button" title="emoreno_1-1718305188539.png" alt="emoreno_1-1718305188539.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 19:23:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-code-for-field-calculation/m-p/1492012#M84552</guid>
      <dc:creator>emoreno</dc:creator>
      <dc:date>2024-06-13T19:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using Code for Field Calculation</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-code-for-field-calculation/m-p/1495662#M84816</link>
      <description>&lt;P&gt;Caveat, I used ChatGPT to write this Arcade expression based upon the statement - "&lt;SPAN&gt;Write an arcade expression that calculates a field called Drop_Length_Total in a layer called DoubleD where if a line layer called DTTERM touches a point layer called VSP, I'd like the shape_length of the DTTERM layer to be added to the shape_length of a layer called DTTAP that also intersects the same VSP point."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The script completed is as follows - haven't tested it as I don't have the same data as you:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;// Initialize the total drop length variable&lt;BR /&gt;var dropLengthTotal = 0;&lt;/P&gt;&lt;P&gt;// Access the DTTERM layer&lt;BR /&gt;var dttermLayer = FeatureSetByName($map, "DTTERM");&lt;/P&gt;&lt;P&gt;// Access the DTTAP layer&lt;BR /&gt;var dttapLayer = FeatureSetByName($map, "DTTAP");&lt;/P&gt;&lt;P&gt;// Access the VSP points layer&lt;BR /&gt;var vspLayer = FeatureSetByName($map, "VSP");&lt;/P&gt;&lt;P&gt;// Loop through each VSP point&lt;BR /&gt;for (var vspPoint in vspLayer) {&lt;BR /&gt;// Find DTTERM lines that touch the current VSP point&lt;BR /&gt;var touchingDTTERM = Intersects(dttermLayer, vspPoint);&lt;BR /&gt;&lt;BR /&gt;// Find DTTAP lines that intersect the same VSP point&lt;BR /&gt;var intersectingDTTAP = Intersects(dttapLayer, vspPoint);&lt;BR /&gt;&lt;BR /&gt;// Initialize variables to hold lengths&lt;BR /&gt;var dttermLength = 0;&lt;BR /&gt;var dttapLength = 0;&lt;BR /&gt;&lt;BR /&gt;// Sum the lengths of touching DTTERM lines&lt;BR /&gt;for (var line in touchingDTTERM) {&lt;BR /&gt;dttermLength += line.shape_length;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;// Sum the lengths of intersecting DTTAP lines&lt;BR /&gt;for (var line in intersectingDTTAP) {&lt;BR /&gt;dttapLength += line.shape_length;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;// Sum the lengths for the current VSP point&lt;BR /&gt;var totalLengthForVSP = dttermLength + dttapLength;&lt;BR /&gt;&lt;BR /&gt;// Add to the total drop length&lt;BR /&gt;dropLengthTotal += totalLengthForVSP;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Return the total drop length&lt;BR /&gt;return dropLengthTotal;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 20:59:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-code-for-field-calculation/m-p/1495662#M84816</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2024-06-20T20:59:09Z</dc:date>
    </item>
  </channel>
</rss>

