Select to view content in your preferred language

Summarizing Treartment Types after polygon Intersect Arcade

282
2
Jump to solution
04-01-2025 04:12 PM
Labels (1)
ErinHeiselmann1
New Contributor

I'm trying to summarize Proposed Action Treatment acres using the Implementation Treatment polygon feature using arcade. I have a layer of Proposed Action Treatments  and a layer for Implementation Treatment units. When I click on an Implementation Treatment unit I want the pop-up to summarize the Proposed Action Treatment Type acres (there can be multiple).  I'm having issues with my result variables, they are not displaying values just the words I'm putting in.  I feel like I'm close but ran out of time and brain power to troubleshoot.  Any suggestion on how to get the data results to appear in my pop-up correctly? Below is how the expression appears in the pop-up.  Unit 9 ( in yellow) has 4 Proposed Action Treatment types.  These are what I'm trying to summarize in the pop-up but I'm just getting the words and not summaries.   

ErinHeiselmann1_0-1743549107551.png

 

 

 

Here is my arcade expression:

//list proposed action treatments in an implementation polygon with acres.

//get the feature from Proposed Action Treatments layer overlapped by implementation polygon
var treat = Intersects(FeatureSetByName($map, "Proposed Treatments"), $feature)

//create a dictionary that stores the areas for each proposed action treatment type
var treat_areas = Dictionary()
//create a variable that stores the sum of all proposed action treatment areas
var treat_area_sum = 0

//set the variable to hold the total amount of area of the proposed action treatments within the implementation polygon
var treat_type_sum = 0;



//loop over the proposed action treatment polygons
for(var s in treat) {
  //get the area of the intersection
  var a = Area(Intersection($feature, s), "acre")
  //add it to the sum
  treat_area_sum += a
  //store it in the dictionary
  var type = s.Treat_Group
  if(HasKey(treat_areas, type)) {
  treat_areas[type] += a;
  }else{
  treat_areas[type] = a
  treat_type_sum = treat_type_sum + 1;
    }
}

//get some result info
var result = [
  'The total area of the Implemented Unit is ${Round(Area($feature, "acres"))} Acres.'
]


//loop over PA treatment types and append area
for (var type in treat_areas) {
  var a = treat_areas[type]
  var p = a / treat_area_sum * 100
  Push(result, '${type} ---- ${Round(p, 2)}% or ${Round(a, 2)} acres')
}

return Concatenate(result, TextFormatting.NewLine)
 
 
 
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

When using '${}' syntax, you have to use a back tick instead of a regular quote. This is called a template literal 

Push(result, `${type} ---- ${Round(p, 2)}% or ${Round(a, 2)} acres`)

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

When using '${}' syntax, you have to use a back tick instead of a regular quote. This is called a template literal 

Push(result, `${type} ---- ${Round(p, 2)}% or ${Round(a, 2)} acres`)

ErinHeiselmann1
New Contributor

Thanks you! The back tick produced the result I needed! 

0 Kudos