<?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 Return all values inside buffer using arcade in ArcGIS Online Developers Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-developers-questions/return-all-values-inside-buffer-using-arcade/m-p/1258163#M1203</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have this code which sort values base on buffer 1320 feet and return First values. I want to return all values inside the buffer not just one. is it any way I can do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// If the feature doesn't have a geometry, return null
if (IsEmpty(Geometry($feature))) { return null }
// Get the bus stops layer
// To customize, replace the layer name below
var busStops = FeatureSetByName($map,"RTD Active Bus Stops")
// Buffer the current location and intersect with the bus stops
var bufferedLocation = Buffer($feature, 1000, 'feet')
var candidateStops = Intersects(busStops, bufferedLocation)
// Calculate the distance between the bus stops and the current location
// Store the feature and distance as a dictionary and push it into an array
var featuresWithDistances = []
for (var f in candidateStops) {
    Push(featuresWithDistances, 
        {
            'distance': Distance($feature, f, 'feet'),
            'feature': f
        }
    )
}
// Sort the candidate bus stops by distance using a custom function
function sortByDistance(a, b) {
    return a['distance'] - b['distance']
}
var sorted = Sort(featuresWithDistances, sortByDistance)
// Get the closest bus stop
var closestFeatureWithDistance = First(sorted)
// If there was no bus stop, return null
if (IsEmpty(closestFeatureWithDistance)) { return null }
// Return the bus stop name attribute value
// To customize, replace the field name "STOPNAME" below
return `${closestFeatureWithDistance['feature']['STOPNAME']}`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2023 19:39:56 GMT</pubDate>
    <dc:creator>anonymous55</dc:creator>
    <dc:date>2023-02-14T19:39:56Z</dc:date>
    <item>
      <title>Return all values inside buffer using arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/return-all-values-inside-buffer-using-arcade/m-p/1258163#M1203</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have this code which sort values base on buffer 1320 feet and return First values. I want to return all values inside the buffer not just one. is it any way I can do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// If the feature doesn't have a geometry, return null
if (IsEmpty(Geometry($feature))) { return null }
// Get the bus stops layer
// To customize, replace the layer name below
var busStops = FeatureSetByName($map,"RTD Active Bus Stops")
// Buffer the current location and intersect with the bus stops
var bufferedLocation = Buffer($feature, 1000, 'feet')
var candidateStops = Intersects(busStops, bufferedLocation)
// Calculate the distance between the bus stops and the current location
// Store the feature and distance as a dictionary and push it into an array
var featuresWithDistances = []
for (var f in candidateStops) {
    Push(featuresWithDistances, 
        {
            'distance': Distance($feature, f, 'feet'),
            'feature': f
        }
    )
}
// Sort the candidate bus stops by distance using a custom function
function sortByDistance(a, b) {
    return a['distance'] - b['distance']
}
var sorted = Sort(featuresWithDistances, sortByDistance)
// Get the closest bus stop
var closestFeatureWithDistance = First(sorted)
// If there was no bus stop, return null
if (IsEmpty(closestFeatureWithDistance)) { return null }
// Return the bus stop name attribute value
// To customize, replace the field name "STOPNAME" below
return `${closestFeatureWithDistance['feature']['STOPNAME']}`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 19:39:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/return-all-values-inside-buffer-using-arcade/m-p/1258163#M1203</guid>
      <dc:creator>anonymous55</dc:creator>
      <dc:date>2023-02-14T19:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Return all values inside buffer using arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/return-all-values-inside-buffer-using-arcade/m-p/1258199#M1204</link>
      <description>&lt;P&gt;To return all the values for the features in the buffer, you have to &lt;A href="https://developers.arcgis.com/arcade/guide/loops/#featureset" target="_self"&gt;loop&lt;/A&gt; through the sorted FeatureSet and extract the value from each feature. You can &lt;A href="https://developers.arcgis.com/arcade/function-reference/array_functions/#push" target="_self"&gt;add&lt;/A&gt; each of the values into an array, then return the c&lt;A href="https://developers.arcgis.com/arcade/function-reference/text_functions/#concatenate" target="_self"&gt;oncatenated&lt;/A&gt; result.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var output= [];
for (var f in sorted){
  Push(output, f.STOPNAME)
}
return Concatenate(output,`/n`);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 20:43:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/return-all-values-inside-buffer-using-arcade/m-p/1258199#M1204</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-02-14T20:43:29Z</dc:date>
    </item>
  </channel>
</rss>

