<?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: Calculate Distance Between Points - Arcade in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/221510#M10937</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/367175"&gt;Josh Harris&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The short answer is yes you can. However, you will need to consider performance and be smart on determining the nearest point. Als the other service should be in the same map or in the same datastore to have access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can access the other service and start processing each feature one by one to determine the nearest point. If the service has a lot of points, this will come with a cost (performance wise). You can reduce the number of features to process if you have some idea about the maximum distance in which you are sure to find a point. This would allow you to create buffer around the input&amp;nbsp;feature, and use the Intersects function to query the other layer and&amp;nbsp;after that loop through the subset of feature to get to the nearest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So to provide you with some more advise, it would be necessary to share how many feature you have in the other feature service and if there is a distance you can define to&amp;nbsp;avoid processing a large quantity of features.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jul 2020 13:13:00 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2020-07-16T13:13:00Z</dc:date>
    <item>
      <title>Calculate Distance Between Points - Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/221509#M10936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was wondering if it was possible to calculate the distance from one point feature to the nearest point (a separate feature service),&amp;nbsp; and having this distance as a popup, using Arcade?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2020 12:43:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/221509#M10936</guid>
      <dc:creator>RonParis</dc:creator>
      <dc:date>2020-07-16T12:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distance Between Points - Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/221510#M10937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/367175"&gt;Josh Harris&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The short answer is yes you can. However, you will need to consider performance and be smart on determining the nearest point. Als the other service should be in the same map or in the same datastore to have access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can access the other service and start processing each feature one by one to determine the nearest point. If the service has a lot of points, this will come with a cost (performance wise). You can reduce the number of features to process if you have some idea about the maximum distance in which you are sure to find a point. This would allow you to create buffer around the input&amp;nbsp;feature, and use the Intersects function to query the other layer and&amp;nbsp;after that loop through the subset of feature to get to the nearest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So to provide you with some more advise, it would be necessary to share how many feature you have in the other feature service and if there is a distance you can define to&amp;nbsp;avoid processing a large quantity of features.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2020 13:13:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/221510#M10937</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2020-07-16T13:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distance Between Points - Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/221511#M10938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the prompt response. That's great. So the scenario is that I have a webmap with two hosted feature services (Point 1, Point 2). Both feature services are being updated on a&amp;nbsp;daily&amp;nbsp;basis, and will hold at maximum ~30,000 records. I am only interested in distances &amp;lt;= 500m. Initially I thought the Distance or DistanceGeodetic would give me what I was after, but I kept getting "Illegal Argument" error. Am I on the right path with this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2020 13:31:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/221511#M10938</guid>
      <dc:creator>RonParis</dc:creator>
      <dc:date>2020-07-16T13:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distance Between Points - Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/221512#M10939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/367175" target="_blank"&gt;Josh Harris&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example expression that you can use:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; fs &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;FeatureSetByName&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;$map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"The Name of the other point feature service"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; buf &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Buffer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;$feature&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;500&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"meter"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; fs_filtered &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Intersects&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fs&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; buf&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; cnt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Count&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fs_filtered&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; min_dist &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;999&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;cnt &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; f &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fs_filtered&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; dist &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Distance&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;$feature&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; f&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dist &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; min_dist&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
            min_dist &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dist&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
            &lt;SPAN class="comment token"&gt;// if you want to know which feature is nearest, &lt;/SPAN&gt;
            &lt;SPAN class="comment token"&gt;// you should extract that here&lt;/SPAN&gt;
        &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; min_dist&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:48:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/221512#M10939</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T10:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distance Between Points - Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/221513#M10940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Spot on &lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;‌, that works perfectly thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2020 14:46:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/221513#M10940</guid>
      <dc:creator>RonParis</dc:creator>
      <dc:date>2020-07-16T14:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distance Between Points - Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/1140112#M44097</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm digging this old post up. I'm looking to retrieve a specific attribute from the nearest feature (e.g I want to grab the asset ID from the nearest feature. I've tried tweaking the above expression, but it doesn't seem to be reliable in what it's retrieving. Any help would be greatly appreciated.&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com/'), '[item_id]', 0);
var buf = Buffer($feature, 500, "meter");
var fs_filtered = Intersects(fs, buf);
var cnt = Count(fs_filtered);

var min_dist = 999;
if (cnt &amp;gt; 0) {
    for (var f in fs_filtered) {
        var dist = DistanceGeodetic($feature, f);
        if (dist &amp;lt; min_dist) {
            min_dist = dist;
        }
    }
}

return f.[field_name];&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 02 Feb 2022 22:41:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/1140112#M44097</guid>
      <dc:creator>RonParis</dc:creator>
      <dc:date>2022-02-02T22:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distance Between Points - Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/1140499#M44133</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/78890"&gt;@RonParis&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;A couple of changes (you are close):&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Connect to featureset
var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com/'), '[item_id]', 0); 

// define the field name with the information you are looking for
var field_name = "Your Field Name goes here";

// buffer, filter and count (unchanged)
var buf = Buffer($feature, 500, "meter"); 
var fs_filtered = Intersects(fs, buf); 
var cnt = Count(fs_filtered); 

// some initial values
var min_dist = 999; 
var result = "No feature found";

// first check if you have feature in the search distance
if (cnt &amp;gt; 0) { 
    // loop through the features found
    for (var f in fs_filtered) { 
        // calculate distance
        var dist = DistanceGeodetic($feature, f); 
        // check if it is closer than previous results
        if (dist &amp;lt; min_dist) { 
            // got a hot, change the min dist and read the field
            min_dist = dist; 
            result = f[field_name];
        } 
    } 
}

// return the result
return result; &lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 03 Feb 2022 19:26:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/1140499#M44133</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2022-02-03T19:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distance Between Points - Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/1141404#M44187</link>
      <description>&lt;P&gt;Awesome as always&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;,thanks for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 22:14:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/1141404#M44187</guid>
      <dc:creator>RonParis</dc:creator>
      <dc:date>2022-02-07T22:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distance Between Points - Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/1364583#M56538</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;Hello&amp;nbsp;&lt;BR /&gt;Is there anyway I can filter the latest point I created based on the date of creation field and use that point to&lt;BR /&gt;calculate the distance to the new point?&lt;BR /&gt;Basically I need to calculate the distance between the previous point and the newly created point each time.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 19:18:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/1364583#M56538</guid>
      <dc:creator>anonymous55</dc:creator>
      <dc:date>2023-12-27T19:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distance Between Points - Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/1374277#M57066</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering if we can calculate distance of two points from the mid point and auto populates it using attribute rule.&lt;/P&gt;&lt;P&gt;I am having feature class which has electric poles and I want to calculate distance between each poles and calculates it in second feature class.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 07:06:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-distance-between-points-arcade/m-p/1374277#M57066</guid>
      <dc:creator>Yogesh0172</dc:creator>
      <dc:date>2024-01-25T07:06:57Z</dc:date>
    </item>
  </channel>
</rss>

