<?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: Best Practices for Attribute Rules in Roads and Highways User Group (RHUG) Questions</title>
    <link>https://community.esri.com/t5/roads-and-highways-user-group-rhug-questions/best-practices-for-attribute-rules/m-p/1574196#M796</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for those snippets as they are very helpful. We're new to these processes in MT. I saw your presentation for RHUG and it was also very helpful.&lt;/P&gt;&lt;P&gt;I'm working on a data check that will flag in red (validation attribute rule) any median that DOES NOT have a divided highway. I used the code above and added an extra condition to exclude evaluation for Two Way Left Turn medians. I'm getting weird behavior. It ignores TWLT as expected, but it still flags things that have a divided highway. Here is my code and a pic. In the pic, the 2 lonely lines at the top are correctly flagged because I removed their divided highways. The other two longer roads (that cross each other) have a divided hwy but still get flagged. I'm stumped on this one. I confirmed that the lines do overlap. Same ROUTE_ID, begin and end. They do have Z values if that matters&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Only evaluate $features that have geometry and are active (TO_DATE is null)
if ((geometry($feature) != null) &amp;amp;&amp;amp; $feature.TO_DATE == null &amp;amp;&amp;amp; $feature.MEDIAN == "Two Way Left Turn Lane") {
  var routeID = $feature.ROUTE_ID
  var objectID = $feature.OBJECTID
  
  // Get 'Carto Feature' feature set
  var cartoFS = FeatureSetByName($datastore, 'Divided_Highway_Export')
  // Define the SQL query definition query to filter the feature set
  var sql = "ROUTE_ID = @routeID AND TO_DATE IS NULL"
  // Filter the feature set to only return active records where the Route ID is equal to the $feature being evaluated
  var cartoActive = Filter(cartoFS, sql)

  // For each of the features returned in the Filtered feature set  
  for (var c in cartoActive) {
    if (overlaps($feature, c)) { // If the $feature overlaps the feature from the feature set...
      // Return the error message
      return {"errorMessage": `Feature overlaps an activeCarto segment. Route ID: ${routeID}, Object ID: ${objectID}`
    }
  }
}
return true
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jan 2025 22:57:30 GMT</pubDate>
    <dc:creator>Smileyk_mdt</dc:creator>
    <dc:date>2025-01-09T22:57:30Z</dc:date>
    <item>
      <title>Best Practices for Attribute Rules</title>
      <link>https://community.esri.com/t5/roads-and-highways-user-group-rhug-questions/best-practices-for-attribute-rules/m-p/1572867#M791</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm working on some validation attribute rules for data checks for our road log. I seem to get false positives on these checks often because I can't get the rules to filter to exclude retired routes. What are best practices when running attribute rule checks so that the retired routes (TO_DATE is Not NULL) don't show up in the results? I tried filtering using arcade but no success. It also doesn't seem to honor definition queries.&lt;/P&gt;&lt;P&gt;The error inspector window appears to be buggy at times. It doesn't refresh after I alter a rule. I'm running Pro 3.3&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 18:41:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/roads-and-highways-user-group-rhug-questions/best-practices-for-attribute-rules/m-p/1572867#M791</guid>
      <dc:creator>Smileyk_mdt</dc:creator>
      <dc:date>2025-01-06T18:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices for Attribute Rules</title>
      <link>https://community.esri.com/t5/roads-and-highways-user-group-rhug-questions/best-practices-for-attribute-rules/m-p/1573694#M794</link>
      <description>&lt;P&gt;Hi there! We at MnDOT are using an If-then statement at the beginning of our Validations where we want to exclude retired records or records that have null geometry. Here's an example:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Only evaluate active features that have geometry
If ((geometry($feature) != null) &amp;amp;&amp;amp; $feature.TO_DATE == null) {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;For filtering Feature sets, we define a SQL query and use the Filter function:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByName($datastore, 'featureset')
var sql = "TO_DATE IS NULL"
var fsFilter = Filter(fs, sql)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;And here's an example of code that we use to evaluate if a line segment from the filtered Feature Set overlaps the record being evaluated in the Validation&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Only evaluate $features that have geometry and are active (TO_DATE is null)
if ((geometry($feature) != null) &amp;amp;&amp;amp; $feature.TO_DATE == null) {
  var routeID = $feature.ROUTE_ID
  var objectID = $feature.OBJECTID
  
  // Get 'Carto Feature' feature set
  var cartoFS = FeatureSetByName($datastore, 'Carto Feature')
  // Define the SQL query definition query to filter the feature set
  var sql = "ROUTE_ID = @routeID AND TO_DATE IS NULL"
  // Filter the feature set to only return active records where the Route ID is equal to the $feature being evaluated
  var cartoActive = Filter(cartoFS, sql)

  // For each of the features returned in the Filtered feature set  
  for (var c in cartoActive) {
    if (overlaps($feature, c)) { // If the $feature overlaps the feature from the feature set...
      // Return the error message
      return {"errorMessage": `Feature overlaps an activeCarto segment. Route ID: ${routeID}, Object ID: ${objectID}`}
    }
  }
}
return true&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 20:13:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/roads-and-highways-user-group-rhug-questions/best-practices-for-attribute-rules/m-p/1573694#M794</guid>
      <dc:creator>James_Blouin</dc:creator>
      <dc:date>2025-01-17T20:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices for Attribute Rules</title>
      <link>https://community.esri.com/t5/roads-and-highways-user-group-rhug-questions/best-practices-for-attribute-rules/m-p/1574196#M796</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for those snippets as they are very helpful. We're new to these processes in MT. I saw your presentation for RHUG and it was also very helpful.&lt;/P&gt;&lt;P&gt;I'm working on a data check that will flag in red (validation attribute rule) any median that DOES NOT have a divided highway. I used the code above and added an extra condition to exclude evaluation for Two Way Left Turn medians. I'm getting weird behavior. It ignores TWLT as expected, but it still flags things that have a divided highway. Here is my code and a pic. In the pic, the 2 lonely lines at the top are correctly flagged because I removed their divided highways. The other two longer roads (that cross each other) have a divided hwy but still get flagged. I'm stumped on this one. I confirmed that the lines do overlap. Same ROUTE_ID, begin and end. They do have Z values if that matters&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Only evaluate $features that have geometry and are active (TO_DATE is null)
if ((geometry($feature) != null) &amp;amp;&amp;amp; $feature.TO_DATE == null &amp;amp;&amp;amp; $feature.MEDIAN == "Two Way Left Turn Lane") {
  var routeID = $feature.ROUTE_ID
  var objectID = $feature.OBJECTID
  
  // Get 'Carto Feature' feature set
  var cartoFS = FeatureSetByName($datastore, 'Divided_Highway_Export')
  // Define the SQL query definition query to filter the feature set
  var sql = "ROUTE_ID = @routeID AND TO_DATE IS NULL"
  // Filter the feature set to only return active records where the Route ID is equal to the $feature being evaluated
  var cartoActive = Filter(cartoFS, sql)

  // For each of the features returned in the Filtered feature set  
  for (var c in cartoActive) {
    if (overlaps($feature, c)) { // If the $feature overlaps the feature from the feature set...
      // Return the error message
      return {"errorMessage": `Feature overlaps an activeCarto segment. Route ID: ${routeID}, Object ID: ${objectID}`
    }
  }
}
return true
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 22:57:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/roads-and-highways-user-group-rhug-questions/best-practices-for-attribute-rules/m-p/1574196#M796</guid>
      <dc:creator>Smileyk_mdt</dc:creator>
      <dc:date>2025-01-09T22:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices for Attribute Rules</title>
      <link>https://community.esri.com/t5/roads-and-highways-user-group-rhug-questions/best-practices-for-attribute-rules/m-p/1576915#M798</link>
      <description>&lt;P&gt;Hey. Glad to help! Looking at your explanation and code, I can see a couple of things that might be causing the code to return an undesired result.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;EM&gt;&lt;STRONG&gt;added an extra condition to exclude evaluation for Two Way Left Turn medians&lt;/STRONG&gt;&lt;/EM&gt;.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P class="lia-indent-padding-left-30px"&gt;If you are trying to exclude those values from evaluation, then you might want to change the code to use the &lt;FONT color="#FF0000"&gt;!=&lt;/FONT&gt; (inequality operator) instead of the &lt;FONT color="#FF0000"&gt;==&lt;/FONT&gt; (equality operator) for your $feature.MEDIAN value check.&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;U&gt;&lt;STRONG&gt;So change from this (&lt;FONT color="#FF0000"&gt;equals)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;$feature.MEDIAN &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;==&lt;/STRONG&gt;&lt;/FONT&gt; "Two Way Left Turn Lane"&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;U&gt;&lt;STRONG&gt;To this (&lt;FONT color="#FF0000"&gt;does not equal)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;$feature.MEDIAN &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;!=&lt;/STRONG&gt;&lt;/FONT&gt; "Two Way Left Turn Lane"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The other important (and often confusing) thing to consider is which "out-of-the-box" spatial relationship in Arcade should you choose to evaluate the geometry of your two features. Esri has a great resource to play around with geometry types and their spatial relationships here:&amp;nbsp;&lt;A href="https://developers.arcgis.com/documentation/spatial-analysis-services/geometry-analysis/spatial-relationship/" target="_blank" rel="noopener"&gt;Spatial relationships | Documentation | Esri Developer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you're looking to find median line segments that do not exist on a divided-highway, then the overlaps function might not work for you. It seems that you might want to try "&lt;A href="https://developers.arcgis.com/arcade/function-reference/geometry_functions/#disjoint" target="_self"&gt;disjoint&lt;/A&gt;" instead.&lt;/P&gt;&lt;P&gt;Here's the section of the code updated to use the disjoint function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// For each of the features returned in the Filtered feature set  
for (var c in cartoActive) {
  if (disjoint($feature, c)) { // If disjoint is true
    // Return the error message
    return {"errorMessage": `Median feature does not exist on a divided highway. Route ID: ${routeID}, Object ID: ${objectID}`}
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If disjoint doesn't work or you need a spatial relationship check that is more complex than the "out-of-the-box" functions, then you might want to explore the &lt;A href="https://developers.arcgis.com/arcade/function-reference/geometry_functions/#relate" target="_self"&gt;relate function&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;This diagram is from MnDOT's RHUG presentation also illustrates the true/false result for various "out-of-the-box" spatial relationships in Arcade:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="spatial_relationship_lines.jpg" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/123560i7944B71196B75712/image-size/large?v=v2&amp;amp;px=999" role="button" title="spatial_relationship_lines.jpg" alt="spatial_relationship_lines.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We found that for most of our checks we needed a function that provided a combination of Overlaps, Within, and Contains (not pictured) and excluded cross-streets and adjacent lines that share a start or endpoint with our feature being evaluated. To accomplish this, we selected the "relate" function that allows us to define any spatial relationship we desire. This function utilizes the Dimensionally Extended 9-Intersection Model (DE-9IM) to define the spatial relationship.&amp;nbsp;Here are a couple of links that dive into the details:&lt;BR /&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/validating-data/custom-spatial-relationships.htm" target="_blank" rel="noopener"&gt;Custom spatial relationships—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://postgis.net/workshops/postgis-intro/de9im.html" target="_blank" rel="noopener"&gt;26. Dimensionally Extended 9-Intersection Model — Introduction to PostGIS&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And here's a snippet that gave us the "Desired result" shown in the diagram above:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;for (var c in cartoActive) {
  if (relate($feature, c, '1********')) { // If true, return errorMessage
    return {"errorMessage": "Feature shares a line segment with cartoActive segment."}
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 22:00:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/roads-and-highways-user-group-rhug-questions/best-practices-for-attribute-rules/m-p/1576915#M798</guid>
      <dc:creator>James_Blouin</dc:creator>
      <dc:date>2025-01-17T22:00:29Z</dc:date>
    </item>
  </channel>
</rss>

