Ahoj znovu! <\/P>
<\/P>
Takže jsem chtěl použít Arcade k vytvoření štítků, které zobrazují změny teploty na meteorologických stanicích. Data ze stanice jsou REST odkaz z nowcast's<\/A> webu a jsou časově povolená, mají několik hodin minulých pozorování stejně jako aktuální v jakémkoli čase. Na každé stanici jsem chtěl vyfiltrovat každé aktuální a -2hodinové pozorování teploty, pak najít rozdíl pro jednoduchou analýzu trendu a zobrazit tento rozdíl. Kód dole funguje až do nalezení teploty pro "aktuální čas - 2 hodiny" (myslím). Nemyslím si, že tuto část píšu správně kvůli tomu, že data jsou časově povolená.. Nebo mi může něco chybět. Nicméně když to spustím, dává mi to jen aktuální teplotu stanice, takže si myslím, že nezískává data před 2 hodinami. Testoval jsem to jen s 1hodinovým časovým krokem a hodnoty byly stále stejné jako aktuální čas. <\/P><\/P>Pokud máte nějaký náhled na práci s časově povolenými vrstvami přes arcade v profilu štítku, byl bych velmi vděčný. Díky! <\/STRONG><\/P><\/P>\/\/ definuj proměnné použité $feature.obstime;$feature["tmdb_f"];<\/P><\/P>\/\/ nastav časy použité pro analýzu trendu<\/P>var current = DateAdd($feature.obstime, 0, "hours")var not_current = DateAdd($feature.obstime, -2, "hours")<\/P><\/P>\/\/ vytáhni hodnoty teplot pro každý výše uvedený čas<\/P>var current_temp = 0 var previous_temp = 0<\/P>if ($feature.obstime == current) { current_temp = $feature["tmdb_f"]}<\/P>else if ($feature.obstime == not_current){ previous_temp = $feature["tmdb_f"]}<\/P>\/\/ odečti aktuální od předchozího<\/P>var temp_trend = current_temp - previous_temp<\/P>return text(temp_trend) <\/P><\/P><\/BODY><\/HTML>
Pokud máte nějaký náhled na práci s časově povolenými vrstvami přes arcade v profilu štítku, byl bych velmi vděčný. Díky! <\/STRONG><\/P><\/P>\/\/ definuj proměnné použité $feature.obstime;$feature["tmdb_f"];<\/P><\/P>\/\/ nastav časy použité pro analýzu trendu<\/P>var current = DateAdd($feature.obstime, 0, "hours")var not_current = DateAdd($feature.obstime, -2, "hours")<\/P><\/P>\/\/ vytáhni hodnoty teplot pro každý výše uvedený čas<\/P>var current_temp = 0 var previous_temp = 0<\/P>if ($feature.obstime == current) { current_temp = $feature["tmdb_f"]}<\/P>else if ($feature.obstime == not_current){ previous_temp = $feature["tmdb_f"]}<\/P>\/\/ odečti aktuální od předchozího<\/P>var temp_trend = current_temp - previous_temp<\/P>return text(temp_trend) <\/P><\/P><\/BODY><\/HTML>
Just noticed that you are looking to do this in the label profile. This will not be possible since the FeatureSetBy functions that you will need are not available in the label profile.
Below an example of what you can do. However, when I tested this, for some strange reason the data retrieved does not correspond to the data I retrieve manually. I will look into it later and see if I can correct the error.
<SPAN class="keyword token">var</SPAN> locid <SPAN class="operator token">=</SPAN> $feature<SPAN class="punctuation token">.</SPAN>locid<SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// "KELP"; </SPAN> <SPAN class="keyword token">var</SPAN> sql <SPAN class="operator token">=</SPAN> <SPAN class="string token">"locid = '"</SPAN> <SPAN class="operator token">+</SPAN> locid <SPAN class="operator token">+</SPAN> <SPAN class="string token">"'"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="token function">Console</SPAN><SPAN class="punctuation token">(</SPAN>sql<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> fldlist <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"locid"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"obstime"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"tmdb_f"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"validtime"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> observations <SPAN class="operator token">=</SPAN> <SPAN class="token function">OrderBy</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="token function">Filter</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="token function">FeatureSetByName</SPAN><SPAN class="punctuation token">(</SPAN>$map<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"Station scale5"</SPAN><SPAN class="punctuation token">,</SPAN> fldlist<SPAN class="punctuation token">,</SPAN> False<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> sql<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"validtime ASC"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> cnt <SPAN class="operator token">=</SPAN> <SPAN class="token function">Count</SPAN><SPAN class="punctuation token">(</SPAN>observations<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="token function">Console</SPAN><SPAN class="punctuation token">(</SPAN>cnt<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> result <SPAN class="operator token">=</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>cnt <SPAN class="operator token">>=</SPAN> <SPAN class="number token">3</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="token function">Console</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"start"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> i <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">for</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">var</SPAN> obs <SPAN class="keyword token">in</SPAN> observations<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> i <SPAN class="operator token">+</SPAN><SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="token function">Console</SPAN><SPAN class="punctuation token">(</SPAN>obs<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="token function">Console</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">" - "</SPAN> <SPAN class="operator token">+</SPAN> i <SPAN class="operator token">+</SPAN> <SPAN class="string token">": "</SPAN> <SPAN class="operator token">+</SPAN> obs<SPAN class="punctuation token">.</SPAN>validtime <SPAN class="operator token">+</SPAN> <SPAN class="string token">" - "</SPAN> <SPAN class="operator token">+</SPAN> obs<SPAN class="punctuation token">.</SPAN>tmdb_f <SPAN class="operator token">+</SPAN> <SPAN class="string token">" - "</SPAN> <SPAN class="operator token">+</SPAN> obs<SPAN class="punctuation token">.</SPAN>obstime<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>i <SPAN class="operator token">==</SPAN> cnt<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> temp_curr <SPAN class="operator token">=</SPAN> obs<SPAN class="punctuation token">.</SPAN>tmdb_f<SPAN class="punctuation token">;</SPAN> <SPAN class="token function">Console</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"found current..."</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>i <SPAN class="operator token">==</SPAN> cnt<SPAN class="number token">-2</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> temp_min2 <SPAN class="operator token">=</SPAN> obs<SPAN class="punctuation token">.</SPAN>tmdb_f<SPAN class="punctuation token">;</SPAN> <SPAN class="token function">Console</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Found minus 2..."</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">var</SPAN> dif_temp <SPAN class="operator token">=</SPAN> temp_curr <SPAN class="operator token">-</SPAN> temp_min2<SPAN class="punctuation token">;</SPAN> result <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Current temperature: "</SPAN> <SPAN class="operator token">+</SPAN> temp_curr <SPAN class="operator token">+</SPAN> <SPAN class="string token">"°F"</SPAN><SPAN class="punctuation token">;</SPAN> result <SPAN class="operator token">+</SPAN><SPAN class="operator token">=</SPAN> TextFormatting<SPAN class="punctuation token">.</SPAN>NewLine <SPAN class="operator token">+</SPAN> <SPAN class="string token">"Temperature 2 hours before: "</SPAN> <SPAN class="operator token">+</SPAN> temp_min2 <SPAN class="operator token">+</SPAN> <SPAN class="string token">"°F"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>dif_temp <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> result <SPAN class="operator token">+</SPAN><SPAN class="operator token">=</SPAN> TextFormatting<SPAN class="punctuation token">.</SPAN>NewLine <SPAN class="operator token">+</SPAN> <SPAN class="string token">"Temperature has increased by "</SPAN> <SPAN class="operator token">+</SPAN> dif_temp <SPAN class="operator token">+</SPAN> <SPAN class="string token">"°F"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>dif_temp <SPAN class="operator token"><</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> result <SPAN class="operator token">+</SPAN><SPAN class="operator token">=</SPAN> TextFormatting<SPAN class="punctuation token">.</SPAN>NewLine <SPAN class="operator token">+</SPAN> <SPAN class="string token">"Temperature has decreased by "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">Abs</SPAN><SPAN class="punctuation token">(</SPAN>dif_temp<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"°F"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN> result <SPAN class="operator token">+</SPAN><SPAN class="operator token">=</SPAN> TextFormatting<SPAN class="punctuation token">.</SPAN>NewLine <SPAN class="operator token">+</SPAN> <SPAN class="string token">"No change in temperature"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">// number of observations less than 3}</SPAN> result <SPAN class="operator token">=</SPAN> <SPAN class="string token">"There are only "</SPAN> <SPAN class="operator token">+</SPAN> cnt <SPAN class="operator token">+</SPAN> <SPAN class="string token">" observations..."</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">return</SPAN> result<SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Just did a little test, but the data does not allow you to use the FeatureSetBy* functions, so there will be no way for Arcade to access the different observations at a single location.
Edit: When the layer is added separately, you do have access, so it is possible. Will post back a solution later.
You are going to face a couple of challanges, although it is possible to access the multitemporal data and try to analyze the trend.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.