geo_point_to_s2cell()geo_point_to_s2cell()

计算地理位置的 S2 单元格字符串值。Calculates the S2 cell token string value for a geographic location.

详细了解 S2 单元格层次结构Read more about S2 cell hierarchy.

语法Syntax

geo_point_to_s2cell(longitude, latitude, level)geo_point_to_s2cell(longitude, latitude, level)

参数Arguments

  • 经度:地理位置的经度值。longitude: Longitude value of a geographic location. 如果 x 是实数且在 [-180, +180] 范围内,则经度 x 将被视为有效 。Longitude x will be considered valid if x is a real number and x is in the range [-180, +180].
  • 纬度:地理位置的纬度值。latitude: Latitude value of a geographic location. 如果 y 是实数且在 [-90, +90] 范围内,则纬度 y 将被视为有效。Latitude y will be considered valid if y is a real number and y in the range [-90, +90].
  • 级别:可选的 int,用于定义请求的单元格级别。level: An optional int that defines the requested cell level. 支持的值范围为 [0, 30]。Supported values are in the range [0, 30]. 如果未指定,则使用默认值 11If unspecified, the default value 11 is used.

返回Returns

给定地理位置的 S2 单元格令牌字符串值。The S2 cell token string value of a given geographic location. 如果坐标或级别无效,则查询将生成空结果。If the coordinates or levels are invalid, the query will produce an empty result.

备注

  • S2 单元格是一个有用的地理空间聚类分析工具。S2 cell can be a useful geospatial clustering tool.
  • S2 单元格共有 31 个级别,面积从最高 0 层的 85,011,012.19km² 到最低 30 层的 00.44cm²。S2 cell has 31 levels of hierarchy with area coverage ranging from 85,011,012.19km² at the highest level 0 to 00.44cm² at the lowest level 30.
  • S2 单元格在级别从 0 增加到 30 时,单元格中心保持良好。S2 cell preserves the cell center well during level increase from 0 to 30.
  • S2 单元格是球面上的一个单元,它的边缘是测地线。S2 cell is a cell on a spherical surface and its edges are geodesics.
  • 对通过经度 x 和纬度 y 计算的 S2 单元格令牌字符串调用 geo_s2cell_to_central_point() 函数,不一定返回 x 和 y。Invoking the geo_s2cell_to_central_point() function on an S2 cell token string that was calculated on longitude x and latitude y won't necessarily return x and y.
  • 有可能两个地理位置非常接近,但有不同的 S2 单元格标记。It's possible that two geographic locations are very close to each other but have different S2 cell tokens.

每个级别值的 S2 单元格近似面积覆盖率S2 cell approximate area coverage per level value

对于每个级别,S2 单元格的大小相似,但不完全相等。For every level, the size of the S2 cell is similar but not exactly equal. 附近的单元格大小趋于相等。Nearby cell sizes tend to be more equal.

级别Level 最小随机单元格边缘长度(英国)Minimum random cell edge length (UK) 最大随机单元格边缘长度(美国)Maximum random cell edge length (US)
00 7842 km7842 km 7842 km7842 km
11 3921 km3921 km 5004 km5004 km
22 1825 km1825 km 2489 km2489 km
33 840 km840 km 1310 km1310 km
44 432 km432 km 636 km636 km
55 210 km210 km 315 km315 km
66 108 km108 km 156 km156 km
77 54 km54 km 78 km78 km
88 27 km27 km 39 km39 km
99 14 km14 km 20 km20 km
1010 7 km7 km 10 km10 km
1111 3 km3 km 5 km5 km
1212 1699 m1699 m 2 km2 km
1313 850 m850 m 1225 m1225 m
1414 425 m425 m 613 m613 m
1515 212 m212 m 306 m306 m
1616 106 m106 m 153 m153 m
1717 53 m53 m 77 m77 m
1818 27 m27 m 38 m38 m
1919 13 m13 m 19 m19 m
2020 7 m7 m 10 m10 m
2121 3 m3 m 5 m5 m
2222 166 cm166 cm 2 m2 m
2323 83 cm83 cm 120 cm120 cm
2424 41 cm41 cm 60 cm60 cm
2525 21 cm21 cm 30 cm30 cm
2626 10 cm10 cm 15 cm15 cm
2727 5 cm5 cm 7 cm7 cm
2828 2 cm2 cm 4 cm4 cm
2929 12 mm12 mm 18 mm18 mm
3030 6 mm6 mm 9 mm9 mm

表源可以在此 S2 单元格统计资源中找到。The table source can be found in this S2 cell statistical resource.

另请参阅 geo_point_to_geohash()See also geo_point_to_geohash().

示例Examples

由 s2cell 聚合的美国风暴事件。US storm events aggregated by s2cell.

美国 s2cell

StormEvents
| project BeginLon, BeginLat
| summarize by hash=geo_point_to_s2cell(BeginLon, BeginLat, 5)
| project geo_s2cell_to_central_point(hash)
| render scatterchart with (kind=map) // map rendering available in Kusto Explorer desktop
print s2cell = geo_point_to_s2cell(-80.195829, 25.802215, 8)
s2cells2cell
88d9b88d9b

以下示例查找坐标组。The following example finds groups of coordinates. 组中的每对坐标都位于 S2 单元格中,最大面积为 1632.45 km²。Every pair of coordinates in the group resides in the S2 cell with a maximum area of 1632.45 km².

datatable(location_id:string, longitude:real, latitude:real)
[
  "A", 10.1234, 53,
  "B", 10.3579, 53,
  "C", 10.6842, 53,
]
| summarize count = count(),                                        // items per group count
            locations = make_list(location_id)                      // items in the group
            by s2cell = geo_point_to_s2cell(longitude, latitude, 8) // s2 cell of the group
s2cells2cell 计数count locationslocations
47b1d47b1d 22 ["A","B"]["A","B"]
47ae347ae3 11 ["C"]["C"]

由于坐标输入无效,以下示例生成空结果。The following example produces an empty result because of the invalid coordinate input.

print s2cell = geo_point_to_s2cell(300,1,8)
s2cells2cell

由于级别输入无效,以下示例生成空结果。The following example produces an empty result because of the invalid level input.

print s2cell = geo_point_to_s2cell(1,1,35)
s2cells2cell

由于级别输入无效,以下示例生成空结果。The following example produces an empty result because of the invalid level input.

print s2cell = geo_point_to_s2cell(1,1,int(null))
s2cells2cell