Hello again!
So I have been wanting to use Arcade to create labels that show temperature changes at weather stations. The station data is a REST link from nowcast's site and is time enabled, having a couple hours of past observations as well as the current at any one time. At each station location, I wanted to filter out each current and -2hour temperature observation, then find the difference for a simple trend analysis and display that difference. The code at the bottom is working up until finding a temperature for "current time - 2 hours" (i think). I don't think I am writing this part correctly due to the data being time enabled.. Or I could be missing something else. However when I run this, it gives me just the current station temperature, so I am thinking it isn't grabbing the data before 2 hours. I tested this with just a 1 hour time step, and the values were still the same as current time.
If you have any insight on working with time enabled layers via arcade in the label profile, it would be much appreciated. Thanks!
// define variables used
$feature.obstime;
$feature["tmdb_f"];
// set the times used for the trend analysis
var current = DateAdd($feature.obstime, 0, "hours")
var not_current = DateAdd($feature.obstime, -2, "hours")
// pull out temp values for each time above
var current_temp = 0
var previous_temp = 0
if ($feature.obstime == current) {
current_temp = $feature["tmdb_f"]
}
else if ($feature.obstime == not_current){
previous_temp = $feature["tmdb_f"]
}
// subtract the current from previous
var temp_trend = current_temp - previous_temp
return text(temp_trend)