Bonjour encore ! <\/P>
<\/P>
Donc, je voulais utiliser Arcade pour créer des étiquettes qui montrent les variations de température aux stations météorologiques. Les données de la station proviennent d'un lien REST du site nowcast's<\/A> et sont activées par le temps, ayant quelques heures d'observations passées ainsi que l'actuelle à tout moment donné. À chaque emplacement de station, je voulais filtrer chaque observation de température actuelle et celle de -2 heures, puis trouver la différence pour une analyse simple de tendance et afficher cette différence. Le code en bas fonctionne jusqu'à trouver une température pour "heure actuelle - 2 heures" (je pense). Je ne pense pas écrire correctement cette partie à cause des données activées par le temps... Ou je pourrais manquer autre chose. Cependant, quand j'exécute cela, il me donne juste la température actuelle de la station, donc je pense qu'il ne récupère pas les données d'il y a 2 heures. J'ai testé cela avec un pas de temps d'une heure seulement, et les valeurs étaient toujours les mêmes que l'heure actuelle. <\/P><\/P>Si vous avez des idées sur la façon de travailler avec des couches activées par le temps via arcade dans le profil d'étiquette, ce serait très apprécié. Merci ! <\/STRONG><\/P><\/P>\/\/ définir les variables utilisées $feature.obstime;$feature["tmdb_f"];<\/P><\/P>\/\/ définir les temps utilisés pour l'analyse de tendance<\/P>var current = DateAdd($feature.obstime, 0, "hours")var not_current = DateAdd($feature.obstime, -2, "hours")<\/P><\/P>\/\/ extraire les valeurs de température pour chaque temps ci-dessus<\/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>\/\/ soustraire l'actuel du précédent<\/P>var temp_trend = current_temp - previous_temp<\/P>return text(temp_trend) <\/P><\/P><\/BODY><\/HTML>
Si vous avez des idées sur la façon de travailler avec des couches activées par le temps via arcade dans le profil d'étiquette, ce serait très apprécié. Merci ! <\/STRONG><\/P><\/P>\/\/ définir les variables utilisées $feature.obstime;$feature["tmdb_f"];<\/P><\/P>\/\/ définir les temps utilisés pour l'analyse de tendance<\/P>var current = DateAdd($feature.obstime, 0, "hours")var not_current = DateAdd($feature.obstime, -2, "hours")<\/P><\/P>\/\/ extraire les valeurs de température pour chaque temps ci-dessus<\/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>\/\/ soustraire l'actuel du précédent<\/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.
You are going to face a couple of challanges, although it is possible to access the multitemporal data and try to analyze the trend.
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.
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>
Thank you very much for the effort with these responses, I have learned a lot with dissecting your workflow for future problems.
Is there anyway to do the first half that uses FeatureSet in ArcPro's attribute editor, then the rest in AGOL's label editor? What would need to happen for the attribute editor in arcpro to run whenever new data come in, updating the layer in AGOL and allowing the label scripts in AGOL (the last part) to run with the new and sorted data? Could I construct a model in model builder for the first part?
I understand that you work for NOAA and might have access to the source data. It would be best to include in the update procedure of the data an additional field that you can use to label on, one that simply describes the change temperature. If this is stored in an actual field, you can also define you symbology on this type of data. I don't see how you would be able to do part in ArcGIS Pro and part of the expression in the label profile of Arcade (although you could have a simple expression that adds the °F to the data for display).
Sounds good, thank you for your help!
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.