Olá novamente! <\/P>
<\/P>
Então, eu queria usar Arcade para criar rótulos que mostram mudanças de temperatura em estações meteorológicas. Os dados da estação são um link REST do site nowcast's<\/A> e são habilitados para tempo, contendo algumas horas de observações passadas, bem como a atual a qualquer momento. Em cada local da estação, eu queria filtrar cada observação de temperatura atual e de -2 horas, depois encontrar a diferença para uma análise simples de tendência e exibir essa diferença. O código na parte inferior está funcionando até encontrar uma temperatura para "tempo atual - 2 horas" (acho). Eu não acho que estou escrevendo essa parte corretamente devido aos dados serem habilitados para tempo.. Ou posso estar perdendo algo mais. No entanto, quando executo isso, ele me dá apenas a temperatura atual da estação, então estou pensando que não está capturando os dados de 2 horas atrás. Testei isso com um passo de tempo de apenas 1 hora, e os valores ainda eram os mesmos do tempo atual. <\/P><\/P>Se você tiver alguma ideia sobre como trabalhar com camadas habilitadas para tempo via arcade no perfil de rótulo, seria muito apreciado. Obrigado! <\/STRONG><\/P><\/P>\/\/ definir variáveis usadas $feature.obstime;$feature["tmdb_f"];<\/P><\/P>\/\/ definir os tempos usados para a análise de tendência<\/P>var current = DateAdd($feature.obstime, 0, "hours")var not_current = DateAdd($feature.obstime, -2, "hours")<\/P><\/P>\/\/ extrair valores de temperatura para cada tempo acima<\/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>\/\/ subtrair o atual do anterior<\/P>var temp_trend = current_temp - previous_temp<\/P>return text(temp_trend) <\/P><\/P><\/BODY><\/HTML>
Se você tiver alguma ideia sobre como trabalhar com camadas habilitadas para tempo via arcade no perfil de rótulo, seria muito apreciado. Obrigado! <\/STRONG><\/P><\/P>\/\/ definir variáveis usadas $feature.obstime;$feature["tmdb_f"];<\/P><\/P>\/\/ definir os tempos usados para a análise de tendência<\/P>var current = DateAdd($feature.obstime, 0, "hours")var not_current = DateAdd($feature.obstime, -2, "hours")<\/P><\/P>\/\/ extrair valores de temperatura para cada tempo acima<\/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>\/\/ subtrair o atual do anterior<\/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.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.