Select to view content in your preferred language

How to query features within attributed radius of a point feature

208
0
07-22-2024 10:51 PM
Labels (2)
BlakeMorrison
Regular Contributor

This is a fairly broad question, with multiple potential answers. I'm a bit unsure on how to best do what I want. I feel a bit silly for having to ask such a basic question 🙂

 

I have point features in a feature service with a radius attribute. I have polygon features in a different feature service. I would like popups for the points to list features from the other feature service which intersect within the points attributed radius. Ideally, I would be able to click each of the listed intersecting features and zoom to the polygon on the map.

 

I have succesfully written an attribute expression which lists the features as text, but all in the one attribute.

 

// Write a script to return a value to show in the pop-up. 
// For example, get the average of 4 fields:
// Average($feature.SalesQ1, $feature.SalesQ2, $feature.SalesQ3, $feature.SalesQ4)
var portal = Portal('https://www.arcgis.com')

var fields = [
    'name_trading',
    'variety1',
]

var fs = FeatureSetByPortalItem(
    portal,
    '############################',     // FeatureService ID that you want to grab fields from.
    0,                                      // Sublayer index, usually 0.
    fields,                                 // Array of fields to grab from the FeatureService.
    False                                   // Include geometry?
)

var featurelist = [];

var radius = $feature.service_area
var buffer = Buffer($feature, radius, 'kilometers')

var inter = Intersects(fs, buffer);

for (var f in inter) {
    
    var name = f["name_trading"];
    var var1 = f["variety1"];

    Push(featurelist, name+" - "+var1);

}

return featurelist

 

 

I've previously written a different function using the following array structure, which I can't work out how to implement in this situation to make each listed feature it's own field. And even if I could, I don't think I can zoom to each feature via a click if I made this display as intended.

 

var newfields = [
          { alias: $feature.variety1 , value: $feature.var1_perc },
          { alias: $feature.variety2 , value: $feature.var2_perc },
          { alias: $feature.variety3 , value: $feature.var3_perc },
];

 

 

 

Alternative ideas that I can't quite get my head around implementing right now:

  • Arcade element in the popup which displays some sort of list. I can <a href> from this, but I don't think I can zoom to features. So might not accomplish what I want still?
  • Click within the point popup maybe, which opens a Near Me tool, inputs the attributed radius as a distance, and return the features within that radius. I just can't quite understand the workflow here.

 

Am I missing a more obvious idea? I would appreciate any ideas or directions anyone has to offer.

0 Kudos
0 Replies