Arcade popup calculations on cascading intersections

63
0
03-16-2021 01:34 PM
Labels (1)
DavidHood2
New Contributor II

What I want to do:

When I click on a project boundary I want to return the Lynx Analysis Units (LAU) that intersect the project boundary.  Then I want to take each of those intersecting LAU’s and calculate the acres of Lynx Habitat broken out by the Structural Stage (field = ‘StructuralStage’) within that entire LAU.

Below is what I’ve started with and I’m close, just can’t figure out what I need to change.  Currently I’m only getting the Structural Stage information for the first LAU.  I would also like to clean up the number formatting to '#,###.#' and add “acres “.  I'm assuming its how I'm compiling the information at the end, but I'm not sure what I need to change as I'm still learning how to use Arcade.

var int_LAUs = Intersects($feature, FeatureSetByName($map,"LynxAnalysisUnits"));

var LynxHabitat = FeatureSetByName($map,"Lynx Habitat - Structural Stages");

var LAU = {}
var ss = {}
var xs = 0
var LH_area = 0

for (var i in int_LAUs){
    var xs = AreaGeodetic(i, 'acres')
    var int_lh = Intersects(i, LynxHabitat)
    if(HasKey(LAU, i.DRAINAGE)){
        LAU[i.DRAINAGE] += xs
    }else{
        LAU[i.DRAINAGE] = xs
    }}
    for (var h in int_lh){
        var lh_area = AreaGeodetic(Intersection(i,h), 'acres')
        if(HasKey(ss, h.StructuralStage)){
            ss[h.StructuralStage] += lh_area
        }else{
            ss[h.StructuralStage] = lh_area
        }
        }
    

var out_str = "Lynx Structural Stage"

for (var d in LAU){
    out_str += '\n' + d + ' LAU: ' + Text(LAU[d], '#,###.#' + ' acres') +'\n' + Text(ss, '#,###.#' + ' acres') 

}

return out_str

 

Screen capture of what my current arcade script is providing.

DavidHood2_0-1615924711708.png

 

0 Kudos
0 Replies