geo_geohash_to_polygon()

计算表示 geohash 矩形区域的多边形。

详细了解 geohash

语法

geo_geohash_to_polygon(geohash)

详细了解语法约定

参数

客户 类型​​ 必需 说明
geohash string geo_point_to_geohash() 计算得出的 geohash 值。 geohash 字符串必须介于 1 到 18 个字符之间。

返回

采用 GeoJSON 格式动态数据类型的多边形。 如果 geohash 无效,则查询会生成 null 结果。

注意

geohash 边缘是直线,不是测地线。 如果 geohash 多边形是某个其他计算的一部分,请考虑使用 geo_polygon_densify() 对其进行致密化。

示例

print GeohashPolygon = geo_geohash_to_polygon("dr5ru");

输出

GeohashPolygon
{
"type": "Polygon",
"coordinates": [
[[-74.00390625, 40.7373046875], [-73.9599609375, 40.7373046875], [-73.9599609375, 40.78125], [-74.00390625, 40.78125], [-74.00390625, 40.7373046875]]]
}

以下示例组合 geohash 多边形的 GeoJSON 几何集合。

// Geohash GeoJSON collection
datatable(lng:real, lat:real)
[
    -73.975212, 40.789608,
    -73.916869, 40.818314,
    -73.989148, 40.743273,
]
| project geohash = geo_point_to_geohash(lng, lat, 5)
| project geohash_polygon = geo_geohash_to_polygon(geohash)
| summarize geohash_polygon_lst = make_list(geohash_polygon)
| project bag_pack(
    "type", "Feature",
    "geometry", bag_pack("type", "GeometryCollection", "geometries", geohash_polygon_lst),
    "properties", bag_pack("name", "Geohash polygons collection"))

输出

Column1
{
"type": "Feature",
"geometry": {"type": "GeometryCollection","geometries": [
{"type": "Polygon", "coordinates": [[[-74.00390625, 40.78125], [-73.9599609375, 40.78125], [-73.9599609375, 40.8251953125],[ -74.00390625, 40.8251953125], [ -74.00390625, 40.78125]]]},
{"type": "Polygon", "coordinates": [[[ -73.9599609375, 40.78125], [-73.916015625, 40.78125], [-73.916015625, 40.8251953125], [-73.9599609375, 40.8251953125], [-73.9599609375, 40.78125]]]},
{"type": "Polygon", "coordinates": [[[-74.00390625, 40.7373046875], [-73.9599609375, 40.7373046875], [-73.9599609375, 40.78125], [-74.00390625, 40.78125], [-74.00390625, 40.7373046875]]]}]
},
"properties": {"name": "Geohash polygons collection"
}}

下面的示例由于 geohash 输入无效而返回 null 结果。

print GeohashPolygon = geo_geohash_to_polygon("a");

输出

GeohashPolygon