こんにちは、またお会いしましたね! <\/P>
<\/P>
私はArcadeを使って、気象観測所での温度変化を表示するラベルを作成したいと思っていました。観測所のデータはnowcastの<\/A>サイトからのRESTリンクで、時間対応されており、過去数時間分の観測値と任意の時点での現在値が含まれています。各観測所の位置で、現在時刻と2時間前の温度観測値をフィルタリングし、その差分を単純な傾向分析として求め、その差分を表示したいと考えました。下記のコードは「現在時刻 - 2時間」の温度を見つけるところまでは動作しているようですが(たぶん)、時間対応データであるためにこの部分の書き方が正しくないと思います。または他に何か見落としている可能性もあります。しかし実行すると、現在の観測所の温度だけが返されるので、2時間前のデータを取得できていないと思われます。1時間ステップで試したところでも、値は現在時刻と同じでした。 <\/P><\/P>もしArcadeで時間対応レイヤーをラベル プロファイルで扱う際の知見があれば、大変ありがたいです。よろしくお願いします! <\/STRONG><\/P><\/P>\/\/ 使用する変数を定義 $feature.obstime;$feature["tmdb_f"];<\/P><\/P>\/\/ 傾向分析に使う時刻を設定<\/P>var current = DateAdd($feature.obstime, 0, "hours")var not_current = DateAdd($feature.obstime, -2, "hours")<\/P><\/P>\/\/ 上記それぞれの時刻の温度値を取得<\/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>\/\/ 現在値から過去値を引く<\/P>var temp_trend = current_temp - previous_temp<\/P>return text(temp_trend) <\/P><\/P><\/BODY><\/HTML>
もしArcadeで時間対応レイヤーをラベル プロファイルで扱う際の知見があれば、大変ありがたいです。よろしくお願いします! <\/STRONG><\/P><\/P>\/\/ 使用する変数を定義 $feature.obstime;$feature["tmdb_f"];<\/P><\/P>\/\/ 傾向分析に使う時刻を設定<\/P>var current = DateAdd($feature.obstime, 0, "hours")var not_current = DateAdd($feature.obstime, -2, "hours")<\/P><\/P>\/\/ 上記それぞれの時刻の温度値を取得<\/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>\/\/ 現在値から過去値を引く<\/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.
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.