チュートリアル: 地理空間視覚エフェクトを作成する

このチュートリアルは、地理空間の視覚化に Kusto 照会言語 (KQL) を使用するユーザー向けです。 地理空間クラスタリングは、地理的な場所に基づいてデータを整理および分析する方法です。 KQL には、 地理空間クラスタリング を実行するための複数の方法と、 地理空間視覚化用のツールが用意されています。

このチュートリアルで学習する内容は次のとおりです。

マップ上にポイントをプロットする

マップ上のポイントを視覚化するには、 プロジェクト を使用して経度を含む列を選択し、次に緯度を含む列を選択します。 次に、render を使用して、 が に設定された散布図で結果をkindmap表示します。

StormEvents
| take 100
| project BeginLon, BeginLat
| render scatterchart with (kind = map)

マップ上のサンプル Storm イベントのスクリーンショット。

複数の一連のポイントをプロットする

複数の一連のポイントを視覚化するには、 project を使用して経度と緯度を選択し、3 番目の列を選択します。これは系列を定義します。

次のクエリでは、系列は です EventType。 ポイントは、 に応じて EventType異なる色付けされ、選択すると列の内容が EventType 表示されます。

StormEvents
| take 100
| project BeginLon, BeginLat, EventType
| render scatterchart with (kind = map)

種類別のマップ上のサンプル Storm イベントのスクリーンショット。

を実行するときに、 xcolumn (経度)、(緯度) ycolumn 、および series を明示的に render指定することもできます。 この仕様は、経度、緯度、系列の列だけでなく、結果に列が多い場合に必要です。

StormEvents
| take 100
| render scatterchart with (kind = map, xcolumn = BeginLon, ycolumns = BeginLat, series = EventType)

GeoJSON 値を使用してマップ上にポイントをプロットする

動的 GeoJSON 値は変更または更新でき、多くの場合、リアルタイム マッピング アプリケーションに使用されます。 動的 GeoJSON 値を使用したマッピング ポイントを使用すると、プレーンな緯度と経度の値では不可能な可能性がある、マップ上のデータの表現をより柔軟に制御できます。

次のクエリでは、 geo_point_to_s2cellgeo_s2cell_to_central_point を使用して、散布図の Storm イベントをマップします。

StormEvents
| project BeginLon, BeginLat
| summarize by hash=geo_point_to_s2cell(BeginLon, BeginLat, 5)
| project point = geo_s2cell_to_central_point(hash)
| project lng = toreal(point.coordinates[0]), lat = toreal(point.coordinates[1])
| render scatterchart with (kind = map)

geojson を使用して表示されるサンプル Storm イベントのスクリーンショット。

可変サイズのバブルを使用してデータ ポイントを表す

各クラスターで集計を実行し、クラスターの中心点をプロットして、データ ポイントの分布を視覚化します。

たとえば、次のクエリでは、"トルネード" イベントの種類のすべての storm イベントをフィルター処理します。 次に、経度と緯度に基づいてイベントをクラスターにグループ化し、各クラスター内のイベントの数をカウントし、クラスターの中心点を投影し、結果を視覚化するためのマップをレンダリングします。 竜巻が最も多い領域は、大きなバブル サイズに基づいて明確に検出されます。

StormEvents
| where EventType == "Tornado"
| project BeginLon, BeginLat
| where isnotnull(BeginLat) and isnotnull(BeginLon)
| summarize count_summary=count() by hash = geo_point_to_s2cell(BeginLon, BeginLat, 4)
| project geo_s2cell_to_central_point(hash), count_summary
| extend Events = "count"
| render piechart with (kind = map)

竜巻嵐の地理空間マップを示す Azure Data Explorer Web UI のスクリーンショット。

特定の領域内のポイントを表示する

多角形を使用して領域を定義し、 geo_point_in_polygon 関数を使用して、その領域内で発生するイベントをフィルター処理します。

次のクエリでは、南カリフォルニアリージョンを表す多角形と、このリージョン内の嵐イベントのフィルターを定義します。 次に、イベントをクラスターにグループ化し、各クラスター内のイベントの数をカウントし、クラスターの中心点を投影し、クラスターを視覚化するためのマップをレンダリングします。

let southern_california = dynamic({
    "type": "Polygon",
    "coordinates": [[[-119.5, 34.5], [-115.5, 34.5], [-115.5, 32.5], [-119.5, 32.5], [-119.5, 34.5]]
    ]});
StormEvents
| where geo_point_in_polygon(BeginLon, BeginLat, southern_california)
| project BeginLon, BeginLat
| summarize count_summary = count() by hash = geo_point_to_s2cell(BeginLon, BeginLat, 8)
| project geo_s2cell_to_central_point(hash), count_summary
| extend Events = "count"
| render piechart with (kind = map)

南カリフォルニアの嵐の地理空間マップを示す Azure Data Explorer Web UI のスクリーンショット。

LineString に近いポイントを表示する

次のクエリでは、定義されたパスを表す、指定した LineString に沿って発生する近くの storm イベントを検索します。 この場合、LineString はキーウエストへの道です。 geo_distance_point_to_line() 関数は、定義された LineString への近接性に基づいて Storm イベントをフィルター処理するために使用されます。 イベントが LineString から 500 メートル以内にある場合、イベントはマップ上にレンダリングされます。

let roadToKeyWest = dynamic({
"type":"linestring",
"coordinates":[
          [
            -81.79595947265625,
            24.56461038017685
          ],
          [
            -81.595458984375,
            24.627044746156027
          ],
          [
            -81.52130126953125,
            24.666986385216273
          ],
          [
            -81.35650634765625,
            24.66449040712424
          ],
          [
            -81.32354736328125,
            24.647017162630366
          ],
          [
            -80.8099365234375,
            24.821639356846607
          ],
          [
            -80.62042236328125,
            24.93127614538456
          ],
          [
            -80.37872314453125,
            25.175116531621764
          ],
          [
            -80.42266845703124,
            25.19251511519153
          ],
          [
            -80.4803466796875,
            25.46063471847754
          ]
        ]});
StormEvents
| where isnotempty(BeginLat) and isnotempty(BeginLon)
| project BeginLon, BeginLat, EventType
| where geo_distance_point_to_line(BeginLon, BeginLat, roadToKeyWest) < 500
| render scatterchart with (kind=map)

LineString に沿ってイベントを計算する前の KQL クエリの結果のスクリーンショット。

ポリゴン内の近くのポイントを表示する

次のクエリでは、指定した多角形内で発生する近くの storm イベントを検索します。 この場合、多角形はキーウエストへの道です。 geo_distance_point_to_polygon() 関数は、定義されたポリゴンへの近接性に基づいて Storm イベントをフィルター処理するために使用されます。 イベントがポリゴンから 500 メートル以内にある場合、イベントはマップ上にレンダリングされます。

let roadToKeyWest = dynamic({
"type":"polygon",
"coordinates":[
          [
            [
              -80.08209228515625,
              25.39117928167583
            ],
            [
              -80.4913330078125,
              25.517657429994035
            ],
            [
              -80.57922363281249,
              25.477992320574817
            ],
            [
              -82.188720703125,
              24.632038149596895
            ],
            [
              -82.1942138671875,
              24.53712939907993
            ],
            [
              -82.13104248046875,
              24.412140070651528
            ],
            [
              -81.81243896484375,
              24.43714786161562
            ],
            [
              -80.58746337890625,
              24.794214972389486
            ],
            [
              -80.08209228515625,
              25.39117928167583
            ]
          ]
        ]});
StormEvents
| where isnotempty(BeginLat) and isnotempty(BeginLon)
| project BeginLon, BeginLat, EventType
| where geo_distance_point_to_polygon(BeginLon, BeginLat, roadToKeyWest) < 500
| render scatterchart with (kind=map)

多角形に沿ってイベントを計算する前の KQL クエリの結果のスクリーンショット。

地理空間データに基づいて異常を検索する

次のクエリでは、特定の状態内で発生する Storm イベントの分析を実行します。 このクエリでは、S2 セルとテンポラル集計を使用して損害のパターンを調査します。 結果は、時間の経過に伴う嵐による破壊の不規則性または逸脱を示す視覚的な異常チャートであり、指定された状態境界内の嵐の影響に関する詳細な視点を提供します。

let stateOfInterest = "Texas";
let statePolygon = materialize(
    US_States
    | extend name = tostring(features.properties.NAME)
    | where name == stateOfInterest
    | project geometry=features.geometry);
let stateCoveringS2cells = statePolygon
    | project s2Cells = geo_polygon_to_s2cells(geometry, 9);
StormEvents
| extend s2Cell = geo_point_to_s2cell(BeginLon, BeginLat, 9)
| where s2Cell in (stateCoveringS2cells)
| where geo_point_in_polygon(BeginLon, BeginLat, toscalar(statePolygon))
| make-series damage = avg(DamageProperty + DamageCrops) default = double(0.0) on StartTime step 7d
| extend anomalies=series_decompose_anomalies(damage)
| render anomalychart with (anomalycolumns=anomalies)

前の KQL クエリによってレンダリングされた異常グラフのスクリーンショット。