<?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 Trace from ribbon vs from exported feature class in Trace Network Questions</title>
    <link>https://community.esri.com/t5/trace-network-questions/trace-from-ribbon-vs-from-exported-feature-class/m-p/205156#M12</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As a workaround for the &lt;A _jive_internal="true" href="https://community.esri.com/thread/262370-trace-tool-not-honoring-feature-selection"&gt;Trace tool not honoring feature selections&lt;/A&gt;, I am trying the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. In Pro 2.6, select the junction feature I'm interested in.&lt;/P&gt;&lt;P&gt;2. Export the feature to a new feature class named Flag in my default geodatabase.&amp;nbsp; Note that my trace network is in another geodatabase.&lt;/P&gt;&lt;P&gt;3. Clear the selection.&lt;/P&gt;&lt;P&gt;4. Run an &lt;STRONG&gt;upstream trace&lt;/STRONG&gt;, using Flag as the Starting Points with all other parameters at defaults.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, in addition to the expected upstream edges, the resulting feature selection includes the edge just &lt;STRONG&gt;downstream&lt;/STRONG&gt; of the junction (orange circle in image below).&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Image of downstream edge being returned in upstream trace results" class="jive-emoji image-1 jive-image j-img-original" src="/legacyfs/online/512609_downstream included.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I instead use the ribbon to interactively set a starting point at the desired junction (I made sure it snapped to that junction feature before clicking), and then run an upstream trace (initiated from the ribbon, so it's using the TN_Temp_Starting_Points and all defaults), I get the desired result, which is just the upstream set of edges.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Only upstream edges returned from upstream trace" class="jive-emoji jive-image image-2 j-img-original" src="/legacyfs/online/512610_trace from ribbon.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why is my exported junction causing a downstream edge to be returned from an upstream trace?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that interactively setting starting points isn't an option for me, because I'm trying to automate this for thousands of junctions via ModelBuilder.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Nov 2020 19:55:27 GMT</pubDate>
    <dc:creator>TimWhiteaker</dc:creator>
    <dc:date>2020-11-05T19:55:27Z</dc:date>
    <item>
      <title>Trace from ribbon vs from exported feature class</title>
      <link>https://community.esri.com/t5/trace-network-questions/trace-from-ribbon-vs-from-exported-feature-class/m-p/205156#M12</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As a workaround for the &lt;A _jive_internal="true" href="https://community.esri.com/thread/262370-trace-tool-not-honoring-feature-selection"&gt;Trace tool not honoring feature selections&lt;/A&gt;, I am trying the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. In Pro 2.6, select the junction feature I'm interested in.&lt;/P&gt;&lt;P&gt;2. Export the feature to a new feature class named Flag in my default geodatabase.&amp;nbsp; Note that my trace network is in another geodatabase.&lt;/P&gt;&lt;P&gt;3. Clear the selection.&lt;/P&gt;&lt;P&gt;4. Run an &lt;STRONG&gt;upstream trace&lt;/STRONG&gt;, using Flag as the Starting Points with all other parameters at defaults.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, in addition to the expected upstream edges, the resulting feature selection includes the edge just &lt;STRONG&gt;downstream&lt;/STRONG&gt; of the junction (orange circle in image below).&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Image of downstream edge being returned in upstream trace results" class="jive-emoji image-1 jive-image j-img-original" src="/legacyfs/online/512609_downstream included.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I instead use the ribbon to interactively set a starting point at the desired junction (I made sure it snapped to that junction feature before clicking), and then run an upstream trace (initiated from the ribbon, so it's using the TN_Temp_Starting_Points and all defaults), I get the desired result, which is just the upstream set of edges.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Only upstream edges returned from upstream trace" class="jive-emoji jive-image image-2 j-img-original" src="/legacyfs/online/512610_trace from ribbon.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why is my exported junction causing a downstream edge to be returned from an upstream trace?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that interactively setting starting points isn't an option for me, because I'm trying to automate this for thousands of junctions via ModelBuilder.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2020 19:55:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/trace-from-ribbon-vs-from-exported-feature-class/m-p/205156#M12</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2020-11-05T19:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Trace from ribbon vs from exported feature class</title>
      <link>https://community.esri.com/t5/trace-network-questions/trace-from-ribbon-vs-from-exported-feature-class/m-p/1006410#M48</link>
      <description>&lt;P&gt;My mistake was simply copying my selected junction to a separate flag feature class. To make this work, I also have to add and populate a couple of fields that you'll notice in the TN_Temp_Starting_Points feature class in your default geodatabase that stores the flags you create interactively (via Data tab on ribbon), namely, SOURCEID and FEATUREGLOBALID. The SOURCEID refers to the identifier given to the junction layer in the trace network. The FEATUREGLOBALID is the GLOBALID of the junction feature where you want the starting point placed.&lt;/P&gt;&lt;P&gt;I discovered this when I noticed that traces initiated from a copy of TN_Temp_Starting_Points worked.&amp;nbsp; I deleted fields one by one and ran traces to see which fields were actually required, leading me to just the two fields I mentioned above.&amp;nbsp; I do not know if that works in all cases.&amp;nbsp; It would be nice if an Esri guru could comment on how to properly make a starting flag feature class.&amp;nbsp; I wish this information had been in a white paper that I had access to.&lt;/P&gt;&lt;P&gt;Here's code that demonstrates how to trace upstream given a junction layer.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy


def get_source_id(network, network_layer):
    d = arcpy.Describe(network_layer)
    fc_name = d.featureClass.name
    
    d = arcpy.Describe(network)
    for s in d.sources:
        if s.name == fc_name:
            return s.sourceID

    arcpy.AddError(
        'Could not determine network source ID for ' + network_layer.name)
    raise arcpy.ExecuteError


def point_to_flag(shape_xy, spatial_ref, source_id, global_id):
    flag_fc = arcpy.CreateFeatureclass_management(
        out_path='memory',
        out_name='flag',
        geometry_type='POINT',
        has_m='ENABLED',
        has_z='ENABLED',
        spatial_reference=spatial_ref)[0]
    flag_fc = arcpy.management.AddField(flag_fc, 'SOURCEID', 'LONG')[0]
    flag_fc = arcpy.management.AddField(flag_fc, 'FEATUREGLOBALID', 'GUID')[0]
    fields = ['SHAPE@XY', 'SOURCEID', 'FEATUREGLOBALID']
    with arcpy.da.InsertCursor(flag_fc, fields) as cursor:
        cursor.insertRow((shape_xy, source_id, global_id))
    return flag_fc


arcpy.env.overwriteOutput = True

network = arcpy.GetParameter(0)
junction_layer = arcpy.GetParameter(1)

spatial_ref = arcpy.Describe(junction_layer).spatialReference
source_id = get_source_id(network, junction_layer)

with arcpy.da.SearchCursor(junction_layer, ['SHAPE@XY', 'GLOBALID']) as cursor:
    for i, row in enumerate(cursor):        
        flag = point_to_flag(row[0], spatial_ref, source_id, row[1])

        Updated_Trace_Network = arcpy.tn.Trace(
            in_trace_network=network,
            trace_type='UPSTREAM',
            starting_points=flag)[0]

arcpy.SetParameter(2, junction_layer)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 22:08:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/trace-from-ribbon-vs-from-exported-feature-class/m-p/1006410#M48</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2020-12-02T22:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Trace from ribbon vs from exported feature class</title>
      <link>https://community.esri.com/t5/trace-network-questions/trace-from-ribbon-vs-from-exported-feature-class/m-p/1007398#M51</link>
      <description>&lt;P&gt;Copying this from a reply in &lt;A href="https://community.esri.com/t5/trace-network-questions/trace-downstream-doesn-t-return-ending-barrier/m-p/1007392/highlight/true#M50" target="_blank" rel="noopener"&gt;another thread&lt;/A&gt;&amp;nbsp; to clarify when SOURECEID and FEATUREGLOBALID fields are used when working with starting points and barriers in a trace network trace.&lt;/P&gt;&lt;P&gt;When placing starting points and barriers in a trace network, the &lt;STRONG&gt;SOURCEID / FEATUREGLOBALID are not required&lt;/STRONG&gt;; however, these fields are honored if present and require the inclusion of valid values to be used.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using SOURCEID and&amp;nbsp; FEATUREGLOBALID&amp;nbsp;to specify trace locations in a feature class allows you to filter which features are used as trace locations.&amp;nbsp; Perhaps you have a feature class that contains features you want to use as barriers; however, you only want a certain type of feature, or specific set of features to serve as barriers...&amp;nbsp; In this case you could populate only the features you want to serve as barriers with SOURCEID/FEATUREGLOBALID information.&amp;nbsp; When the trace is executed, only these features would be used as either the starting point or barrier for the class.&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;To clarify, case, if your class has 20 records, but only 2 have&amp;nbsp;SOURCEID/FEATUREGLOBALID populated with a valid value, only those 2 would be used as starting points or barriers in the trace.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;If these fields are not present, the geometry of the feature class will be used to intersect the network feature geometry and place either the starting point or barrier.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snag_24dd8dda.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/1600i253A151CB48087E9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Snag_24dd8dda.png" alt="Snag_24dd8dda.png" /&gt;&lt;/span&gt;&lt;SPAN class="lia-inline-image-caption"&gt;user-defined feature class used as a barrier feature without SOURCEID/FEATUREGLOBALID&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This is outlined here:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/help/data/trace-network/starting-points.htm" target="_blank" rel="noopener nofollow noopener noreferrer"&gt;https://pro.arcgis.com/en/pro-app/help/data/trace-network/starting-points.htm&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/help/data/trace-network/barriers.htm" target="_blank" rel="noopener nofollow noopener noreferrer"&gt;https://pro.arcgis.com/en/pro-app/help/data/trace-network/barriers.htm&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;If this does not address the original use case above please reach out with additional details and I can review further.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 16:10:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/trace-network-questions/trace-from-ribbon-vs-from-exported-feature-class/m-p/1007398#M51</guid>
      <dc:creator>JonDeRose</dc:creator>
      <dc:date>2020-12-07T16:10:58Z</dc:date>
    </item>
  </channel>
</rss>

