geo_intersection_line_with_polygon()
適用於:✅Microsoft網狀架構✅Azure 數據✅總管 Azure 監視器✅Microsoft Sentinel
計算線條或多行的交集,其中含有多邊形或多面形。
語法
geo_intersection_line_with_polygon(
lineString,
多邊形)
深入瞭解 語法慣例。
參數
姓名 | 類型 | 必要 | 描述 |
---|---|---|---|
lineString | dynamic |
✔️ | GeoJSON 格式的LineString或 MultiLineString。 |
多邊形 | dynamic |
✔️ | GeoJSON 格式的多邊形或 MultiPolygon。 |
傳回
GeoJSON 格式和動態數據類型的交集。 如果lineString或 multiLineString或多邊形或多多邊形無效,則查詢會產生 Null 結果。
注意
- 地理空間座標會解譯為 WGS-84 座標參考系統所代表。
- 用來測量地球上距離的 地緣日期 是球體。 線條邊緣是 球體上的地理區域 。
- 如果輸入線或多邊形邊緣是直線笛卡兒線,請考慮使用 geo_line_densify() 或 geo_polygon_densify() 將平面邊緣轉換成地理座標。
LineString 定義和條件約束
dynamic({“type”: “LineString”,“coordinates”: [[lng_1,lat_1], [lng_2,lat_2], ..., [lng_N,lat_N]})
dynamic({“type”: “MultiLineString”,“coordinates”: [[line_1, line_2, ..., line_N]})
- LineString 座標數位必須至少包含兩個專案。
- 坐標 [經度, 緯度] 必須有效,其中經度是範圍 [-180, +180] 中的實數,而緯度是範圍 [-90, +90] 中的實數。
- 邊緣長度必須小於 180 度。 將選擇兩個頂點之間的最短邊緣。
多邊形定義和條件約束
dynamic({“type”: “Polygon”,“coordinates”: [LinearRingShell, LinearRingHole_1, ..., LinearRingHole_N]})
dynamic({“type”: “MultiPolygon”,“coordinates”: [[LinearRingShell, LinearRingHole_1, ..., LinearRingHole_N],..., [LinearRingShell, LinearRingHole_1, ..., LinearRingHole_M]]})
- LinearRingShell 是必要的,並定義為
counterclockwise
已排序的座標陣列 [[lng_1,lat_1],...,[lng_i,lat_i],...,[lng_j,lat_j],...,[lng_1,lat_1]]。 只能有一個殼層。 - LinearRingHole 是選擇性的,並定義為
clockwise
已排序的座標數位列 [[lng_1,lat_1],...,[lng_i,lat_i],...,[lng_j,lat_j],...,[lng_1,lat_1]]。 可以有任意數量的內環和孔。 - 線性Ring 頂點必須與至少三個座標相異。 第一個座標必須等於最後一個座標。 至少需要四個專案。
- 座標 [經度, 緯度] 必須有效。 經度必須是範圍 [-180, +180] 中的實數,而緯度必須是範圍 [-90, +90] 中的實數。
- LinearRingShell 會括住球體的大部分部分。 LinearRing 會將球體分成兩個區域。 將會選擇這兩個區域中的較小數目。
- LinearRing 邊緣長度必須小於 180 度。 將選擇兩個頂點之間的最短邊緣。
- LinearRings 不得交叉且不得共享邊緣。 LinearRings 可能會共享頂點。
- 多邊形包含其頂點。
提示
使用常值LineString或 MultiLineString 以提升效能。
範例
下列範例會計算線條與多邊形之間的交集。 在此情況下,結果是一行。
let lineString = dynamic({"type":"LineString","coordinates":[[-73.985195,40.788275],[-73.974552,40.779761]]});
let polygon = dynamic({"type":"Polygon","coordinates":[[[-73.9712905883789,40.78580561168767],[-73.98004531860352,40.775276834803655],[-73.97000312805176,40.77852663535664],[-73.9712905883789,40.78580561168767]]]});
print intersection = geo_intersection_line_with_polygon(lineString, polygon)
輸出
交集 |
---|
{“type”: “LineString”,“coordinates”: [[-73.975611956578192,40.78060906714618],[-73.974552,40.779761]]} |
下列範例會計算線條與多邊形之間的交集。 在此情況下,結果是多行。
let lineString = dynamic({"type":"LineString","coordinates":[[-110.522, 39.198],[-91.428, 40.880]]});
let polygon = dynamic({"type":"Polygon","coordinates":[[[-90.263,36.738],[-102.041,45.274],[-109.335,36.527],[-90.263,36.738]],[[-100.393,41.705],[-103.139,38.925],[-97.558,39.113],[-100.393,41.705]]]});
print intersection = geo_intersection_line_with_polygon(lineString, polygon)
輸出
交集 |
---|
{“type”: “MultiLineString”,“coordinates”: [[[ -106.8935365881905, 39.769226209776306],[ -101.74448553679453, 40.373506008712525],[[-99.136499431328858, 40.589336512699994],[-95.284527737311791,40.799060242246348]]]} |
下列行和多邊形不會交集。
let lineString = dynamic({"type":"LineString","coordinates":[[1, 1],[2, 2]]});
let polygon = dynamic({"type":"Polygon","coordinates":[[[-73.9712905883789,40.78580561168767],[-73.98004531860352,40.775276834803655],[-73.97000312805176,40.77852663535664],[-73.9712905883789,40.78580561168767]]]});
print intersection = geo_intersection_line_with_polygon(lineString, polygon)
輸出
交集 |
---|
{“type”: “GeometryCollection”,“geometries”: []} |
下列範例會尋找NYC GeoJSON道路數據表中與感興趣常值多邊形區域交集的所有道路。
let area_of_interest = dynamic({"type":"Polygon","coordinates":[[[-73.95768642425537,40.80065354924362],[-73.9582872390747,40.80089719667298],[-73.95869493484497,40.80050736035672],[-73.9580512046814,40.80019873831593],[-73.95768642425537,40.80065354924362]]]});
NY_Manhattan_Roads
| project name = features.properties.Label, road = features.geometry
| project name, intersection = geo_intersection_line_with_polygon(road, area_of_interest)
| where array_length(intersection.geometries) != 0
輸出
NAME | 交集 |
---|---|
CentralParkW | {“type”:“MultiLineString”,“coordinates”:[-73.958295846836933,40.800316027289647],[-73.9582724,40.8003415]],[[[-73.958413422194482,40.80037239620097],[-73.9584093,40.8003797]]]} |
FrederickDouglassCir | {"type":"LineString","coordinates":[[-73.9579272943862,40.800751229494182],[-73.9579019,40.8007238],[-73.9578688,40.8006749],[-73.9578508,40.8006203],[-73.9578459,40.800570199999996],[-73.9578484,40.80053310000001],[-73.9578627,40.800486700000008],[-73.957913,40.800421100000008],[-73.9579668,40.8003923],[-73.9580189,40.80037260000001],[-73.9580543,40.8003616],[-73.9581237,40.8003395],[-73.9581778,40.8003365],[-73.9582724,40.8003415],[-73.958308,40.8003466],[-73.9583328,40.8003517],[-73.9583757,40.8003645],[-73.9584093,40.8003797],[-73.9584535,40.80041099999999],[-73.9584818,40.8004536],[-73.958507000000012,40.8004955],[-73.9585217,40.800562400000004],[-73.9585282,40.8006155],[-73.958416200000016,40.8007325],[-73.9583541,40.8007785],[-73.9582772,40.800811499999995],[-73.9582151,40.8008285],[-73.958145918999392,40.800839887820239]]} |
W110thSt | {“type”:“MultiLineString”,“coordinates”:[-73.957828446036331,40.800476476316327],[-73 .9578627,40.80048670000008],[[-73.9585282,40.8006155],[--73.958565492035873,40.800631133466972],[[[-73.9584162000000 16,40.8007325],[-73.958446850928084,40.800744577466617]]]} |
WestDr | {“type”:“LineString”,“coordinates”:[[[-73.9580543,40.8003616],[-73.958009693938735,40.800250494588468]]} |
下列範例會尋找與相關常值LineString區域相交的美國所有縣。
let area_of_interest = dynamic({"type":"LineString","coordinates":[[-73.97159099578857,40.794513338780895],[-73.96738529205322,40.792758888618756],[-73.96978855133057,40.789769718601505]]});
US_Counties
| project name = features.properties.NAME, county = features.geometry
| project name, intersection = geo_intersection_line_with_polygon(area_of_interest, county)
| where array_length(intersection.geometries) != 0
輸出
NAME | 交集 |
---|---|
紐約 | {“type”: “LineString”,“coordinates”: [[-73.971590995788574, 40.79451338780895], [-73.967385292053223, 40.792758888618756],[-73.969788551330566, 40.789769718601512]]} |
下列範例會傳回 Null 結果,因為 LineString 無效。
let lineString = dynamic({"type":"LineString","coordinates":[[-73.985195,40.788275]]});
let polygon = dynamic({"type":"Polygon","coordinates":[[[-73.95768642425537,40.80065354924362],[-73.9582872390747,40.80089719667298],[-73.95869493484497,40.80050736035672],[-73.9580512046814,40.80019873831593],[-73.95768642425537,40.80065354924362]]]});
print is_invalid = isnull(geo_intersection_2lines(lineString, polygon))
輸出
is_invalid |
---|
1 |
下列範例會傳回 Null 結果,因為多邊形無效。
let lineString = dynamic({"type":"LineString","coordinates":[[-73.97159099578857,40.794513338780895],[-73.96738529205322,40.792758888618756],[-73.96978855133057,40.789769718601505]]});
let polygon = dynamic({"type":"Polygon","coordinates":[]});
print is_invalid = isnull(geo_intersection_2lines(lineString, polygon))
輸出
is_invalid |
---|
1 |