Select to view content in your preferred language

Arcade Pop-up expression Help

358
1
07-11-2022 06:35 AM
Labels (1)
George_Offer
New Contributor

Hello, I'm tyring to pull through information on habitats from habitats layer within the Site Boundary feature (as $feature) in this pop-up expression. So far it has been working fine when hard coding the Baseline_habitat_Type to match the expected values in the 'habitats layer' features, but i am now developing it to read the unique 'baseline_habitat_type's from the features that intersect and run a for loop off this, any help would be greatly appriciated as to why this is producing the result:

Result Value

Result[ 0 - 0 ha , 1 - 0 ha ]
TypeArray

 

 

var habs = Intersects(
    FeatureSetByName(
        $map,"Habitats Layer",["Site_Code","Baseline_Broad_Habitat","Baseline_Habitat_Type","Baseline_Condition","Shape__Area"]),
        $feature)

//variables
var intcount = count(habs)
var expr = ''
var areaString = ''
var outArr = []
var outArr_index = 0

//generate unique habitat types array
var ListHabs = []
var ListHabs_Index = 0

for (var hab in habs){
    ListHabs[ListHabs_Index] = hab.Baseline_Habitat_Type
            ++ListHabs_Index
}

var UniqListHabs = distinct(ListHabs)

if (intcount > 0){
    for (var UniqListHab in UniqListHabs){
        var UniqListHabArea = 0
        for (var hab in habs){
            if (hab.Baseline_Habitat_Type == UniqListHab){
                UniqListHabArea += hab.Shape_Area
            }
        }
        outarr[outArr_index] = 
        UniqListHab + " - " + round(UniqListHabArea*0.0001, 2) + ' ha' + TextFormatting.NewLine
        ++outArr_index
    }
    expr = Sort(outarr)
}

else{
    expr = 'No Baseline currently mapped or uploaded for ' + $feature["Site_Code"]
}
return expr

 

 

0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

Do you want the output to be a string of the values in the expr array? If so, then just use the Concatenate function

expr = Concatenate(Sort(outarr), ", ");
0 Kudos