<?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: Arcade Expressions (ArcGIS Online) to display nearest ploygon Field Attribute in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expressions-arcgis-online-to-display/m-p/1373405#M57019</link>
    <description>&lt;P&gt;It works! Thanks for sharing&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/188597"&gt;@MikeMillerGIS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2024 12:59:05 GMT</pubDate>
    <dc:creator>MohdZukhairiAbdLatef</dc:creator>
    <dc:date>2024-01-23T12:59:05Z</dc:date>
    <item>
      <title>Arcade Expressions (ArcGIS Online) to display nearest ploygon Field Attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expressions-arcgis-online-to-display/m-p/1371544#M56919</link>
      <description>&lt;P&gt;Hello, I am trying to find nearest feature distance and display its attribute name through pop-ups using Arcade expression in the WebMap (Portal for ArcGIS).&lt;/P&gt;&lt;P&gt;I found below expression from the esri link;&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-display-the-distance-of-the-nearest-point-featur-000029737" target="_blank" rel="noopener"&gt;How To: Display the Distance of the Nearest Point Feature Using an Arcade Expression in Po (esri.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I managed to configure pop-ups and display nearest distance, but I could not figure out how to display its attribute from the result of the nearest distance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my scenario:&lt;/P&gt;&lt;P&gt;Layer 1: BigArea (polygon) [with one field name called "HOUSING PROJECT NAME"]&lt;/P&gt;&lt;P&gt;Layer 2: Land Parcel (Polygon)&lt;/P&gt;&lt;P&gt;I want to display distance and HOUSING PROJECT NAME when I click to any Land Parcel layer. It could me adding another attribute field or using the same distance field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My script I found and modified from ESRI as below:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var BigArea = FeatureSetByName($map,"BigArea");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var buf = Buffer($feature, 2000000, "meter");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var fs_filtered = Intersects(BigArea, buf);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var cnt = Count(fs_filtered);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var min_dist = 2000000;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if (cnt &amp;gt; 0) {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var f in fs_filtered) {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var dist = Distance($feature, f);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (dist &amp;lt; min_dist) {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; min_dist = dist;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;return round(min_dist, 3);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Any suggestions are most welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Zukh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 10:35:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expressions-arcgis-online-to-display/m-p/1371544#M56919</guid>
      <dc:creator>MohdZukhairiAbdLatef</dc:creator>
      <dc:date>2024-01-18T10:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expressions (ArcGIS Online) to display nearest ploygon Field Attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expressions-arcgis-online-to-display/m-p/1371547#M56920</link>
      <description>&lt;P&gt;Dont call Count(), this causes an unnecessary query.&amp;nbsp; Just loop over the results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var BigArea = FeatureSetByName($map,"BigArea");
var buf = Buffer($feature, 2000000, "meter");

var fs_filtered = Intersects(BigArea, buf);

var min_dist = Infinity;
var closest_feat = null;
for (var f in fs_filtered) {

    var dist = Distance($feature, f);

    if (dist &amp;lt; min_dist) {
        closest_feat = f;
        min_dist = dist;

    }
}
if (IsEmpty(closest_feat)){
    return "There are no housing projects withing 2000000 meters"
}
return `${closest_feat.HOUSING PROJECT NAME} is ${round(min_dist, 3)} meters away.`;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 11:19:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expressions-arcgis-online-to-display/m-p/1371547#M56920</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-01-18T11:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expressions (ArcGIS Online) to display nearest ploygon Field Attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expressions-arcgis-online-to-display/m-p/1373405#M57019</link>
      <description>&lt;P&gt;It works! Thanks for sharing&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/188597"&gt;@MikeMillerGIS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 12:59:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expressions-arcgis-online-to-display/m-p/1373405#M57019</guid>
      <dc:creator>MohdZukhairiAbdLatef</dc:creator>
      <dc:date>2024-01-23T12:59:05Z</dc:date>
    </item>
  </channel>
</rss>

