Hi everyone,
I'm working on a dashboard for invasive plant management using iNaturalist observations for the National Park Service and was wondering if it's possible to filter iNat observations based on a list of species the parks deem "invasive".
So far, I tried to write some arcade code to take iNaturalist feature layer (which is a live feed layer) and compare them with a species list I wrote.
The problem I'm running into is that there is no data being populated on the list widget. I'm using the line-item source code to call on the returned data but I'm uncertain on what exactly is causing this issue
My best guess is that somehow, it's not returning correctly since it's in a "if" statement? Attached below is a screenshot of what I'm seeing on the iNaturalist list widget to get a better sense of what I'm talking about.
Here's the arcade advanced formatting code:
// Create a list of all invasive species' scientific names across parks
var invasiveSpeciesList = [
"Agave sisalana", "Albizia julibrissin", "Alternanthera philoxeroides", "Ardisia crenata",
"Casuarina equisetifolia", "Cocos nucifera", "Heptapleuron actinophylla", "Heptapleuron arboricola",
"Imperata cylindrica", "Lonicera japonica", "Lespedeza bicolor", "Ligustrum sinense",
"Liquidambar styraciflua", "Lygodium japonicum", "Lygodium microphyllum", "Melia azedarach",
"Microstegium vimineum", "Paspalum urvillei", "Perilla frutescens", "Phyllostachys aurea",
"Pinus elliottii", "Poncirus trifoliata", "Pteridium aquilinum", "Pueraria montana",
"Salvinia minima", "Salvinia molesta", "Scaevola taccada", "Schinus terebintifolius",
"Thespesia populnea", "Triadica sebifera", "Wisteria sinensis"
]
// Get the species scientific name from the iNaturalist observation
var speciesName = $datapoint.scientific_name;
// Get the species scientific name from the iNaturalist observation
var commonName = $datapoint.common_name;
//Grab the observed on date
var observedOn = $datapoint.observed_on;
// Check if the species name is in the invasive species list
var isInvasive = IndexOf(invasiveSpeciesList, speciesName) > -1;
// If the species is invasive, return its details
if (isInvasive) {
return {
attributes: {
commonName: commonName,
speciesName: speciesName,
observedOn: observedOn
}
};
} else {
// If not invasive, return null to exclude it from the list
return null;
}
And here's my line item source code:
<div style="background-color:#363636;border-left:3px solid white;padding:0.4rem 0.3rem 0.3rem 0.6rem;">
<p>
<span style="font-size:16px;color:white;"><span style="opacity:1;">Common Name: {commonName}</span></span>
</p>
<p>
<span style="font-size:14px;color:white;"><span style="opacity:1;padding:1px;">Scientific Name: {speciesName}</span></span>
</p>
<p>
<span style="font-size:14px;color:white;"><span style="border-radius:5px;opacity:1;padding:1px 6px;">Observed on: {observedOn}</span></span>
</p>
</div>
I've also tried writing the line-item source code using:
Observed on: {expression/observedOn}
But that also didn't work.
And insight or help here would be greatly appreciated 🙂
-Mina