Popup Arcade Expression to display a count of different point features that appear in a selected polygon

887
2
Jump to solution
07-01-2022 07:41 PM
Labels (1)
TobyStewart2
New Contributor II

Hi

I am quite new to Arcade and am stuck trying to create a custom popup in ArcGIS Online.

I have a Local Government Polygon layer for the state and three other point layers:

1. Gasworks

2. Landfill

3. Waste

I am trying to create a popup that will display the total number for each of the  3 sites in that selected Local Government polygon.

I have tried using the Count & Intersect functions but can only get it working for one of the 3.

Any help would be greatly appreciated!

 

 

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor
var gasworks = FeaturesetByName(...)
var gasworks_in_state = Intersects($feature, gasworks)

var landfills = FeaturesetByName(...)
var landfills_in_state = Intersects($feature, landfills)

var waste = FeaturesetByName(...)
var waste_in_state = Intersects($feature, waste)

var point_counts = [
    `gasworks: ${Count(gasworks_in_state)}`,
    `landfills: ${Count(landfills_in_state)}`,
    `waste: ${Count(waste_in_state)}`,
]
return Concatenate(point_counts, TextFormatting.Newline)

Have a great day!
Johannes

View solution in original post

0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor
var gasworks = FeaturesetByName(...)
var gasworks_in_state = Intersects($feature, gasworks)

var landfills = FeaturesetByName(...)
var landfills_in_state = Intersects($feature, landfills)

var waste = FeaturesetByName(...)
var waste_in_state = Intersects($feature, waste)

var point_counts = [
    `gasworks: ${Count(gasworks_in_state)}`,
    `landfills: ${Count(landfills_in_state)}`,
    `waste: ${Count(waste_in_state)}`,
]
return Concatenate(point_counts, TextFormatting.Newline)

Have a great day!
Johannes
0 Kudos
TobyStewart2
New Contributor II

That is awesome @JohannesLindner  works perfectly

Thankyou so very much for that, I really appreciate the help!

0 Kudos