¡Hola de nuevo! <\/P>
<\/P>
He querido usar Arcade para crear etiquetas que muestren cambios de temperatura en estaciones meteorológicas. Los datos de la estación son un enlace REST desde el sitio de nowcast's<\/A> y están habilitados por tiempo, teniendo un par de horas de observaciones pasadas así como la actual en cualquier momento. En cada ubicación de estación, quería filtrar cada observación de temperatura actual y de hace -2 horas, luego encontrar la diferencia para un análisis simple de tendencia y mostrar esa diferencia. El código al final funciona hasta encontrar una temperatura para "tiempo actual - 2 horas" (creo). No creo que esté escribiendo esta parte correctamente debido a que los datos están habilitados por tiempo.. O podría estar perdiendo algo más. Sin embargo, cuando ejecuto esto, solo me da la temperatura actual de la estación, así que pienso que no está obteniendo los datos de hace 2 horas. Probé esto con un paso de tiempo de solo 1 hora, y los valores seguían siendo los mismos que el tiempo actual. <\/P><\/P>Si tienes alguna idea sobre cómo trabajar con capas habilitadas por tiempo vía arcade en el perfil de etiqueta, sería muy apreciado. ¡Gracias! <\/STRONG><\/P><\/P>\/\/ definir variables usadas $feature.obstime;$feature["tmdb_f"];<\/P><\/P>\/\/ establecer los tiempos usados para el análisis de tendencia<\/P>var current = DateAdd($feature.obstime, 0, "hours")var not_current = DateAdd($feature.obstime, -2, "hours")<\/P><\/P>\/\/ extraer valores de temp para cada tiempo arriba<\/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>\/\/ restar el actual del anterior<\/P>var temp_trend = current_temp - previous_temp<\/P>return text(temp_trend) <\/P><\/P><\/BODY><\/HTML>
Si tienes alguna idea sobre cómo trabajar con capas habilitadas por tiempo vía arcade en el perfil de etiqueta, sería muy apreciado. ¡Gracias! <\/STRONG><\/P><\/P>\/\/ definir variables usadas $feature.obstime;$feature["tmdb_f"];<\/P><\/P>\/\/ establecer los tiempos usados para el análisis de tendencia<\/P>var current = DateAdd($feature.obstime, 0, "hours")var not_current = DateAdd($feature.obstime, -2, "hours")<\/P><\/P>\/\/ extraer valores de temp para cada tiempo arriba<\/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>\/\/ restar el actual del 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.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.