地理函数
这个页面列出了 GreptimeDB 中的所有地理空间相关函数。当您启用了
common-function/geo 特性(默认为开启状态)时,这些函数才会生效。
- Geo 数据类型函数
- Geohash
- H3
h3_latlng_to_cellh3_latlng_to_cell_stringh3_cell_to_stringh3_string_to_cellh3_cell_center_latlngh3_cell_resolutionh3_cell_baseh3_cell_is_pentagonh3_cell_parenth3_cell_center_childh3_cell_to_childrenh3_cell_to_children_sizeh3_cell_to_child_posh3_child_pos_to_cellh3_cells_containsh3_grid_diskh3_grid_disk_distancesh3_grid_distanceh3_grid_path_cellsh3_distance_sphere_kmh3_distance_degree
- S2
- 编码
- 空间关系
- 空间测量
Geo 数据类型函数
地理相关数据类型转换。
wkt_point_from_latlng
将纬度、经度转换成 WKT 点。
SELECT wkt_point_from_latlng(37.76938, -122.3889) AS point;
Geohash
了解 更多关于 geohash 编码。
geohash
从纬度、经度和分辨率获取 geohash 编码的字符串。
SELECT geohash(37.76938, -122.3889, 11);
geohash_neighbours
给定坐标和分辨率获取所有 geohash 邻接点。
请注意,此函数返回一个字符串数组,并且仅在我们的 HTTP 查询 API 和 Postgres 通道上生效。
SELECT geohash_neighbours(37.76938, -122.3889, 11);
H3
H3 地理坐标编码算法。了解更多。
h3_latlng_to_cell
将坐标(纬度,经度)编码为指定分辨率下的 h3 索引,并返回该单元格的 UInt64 表示。
SELECT h3_latlng_to_cell(37.76938, -122.3889, 1);
h3_latlng_to_cell_string
类似于 h3_latlng_to_cell ,但返回字符串编码格式。
SELECT h3_latlng_to_cell_string(37.76938, -122.3889, 1);
h3_cell_to_string
将单元格索引(UInt64)转 换为其字符串表示形式。
SELECT h3_cell_to_string(h3_latlng_to_cell(37.76938, -122.3889, 8));
h3_string_to_cell
将十六进制编码的单元 ID 转换为其 UInt64 形式。
SELECT h3_string_to_cell(h3_latlng_to_cell_string(37.76938, -122.3889, 8::UInt64));
h3_cell_center_latlng
返回单元中心的纬度和经度。
请注意,此函数返回一个浮点数数组,并且仅在我们的 HTTP 查询 API 和 Postgres 通道上有效。
SELECT h3_cell_center_latlng(h3_latlng_to_cell(37.76938, -122.3889, 8));
h3_cell_resolution
给定单元格的返回分辨率。
SELECT h3_cell_resolution(h3_latlng_to_cell(37.76938, -122.3889, 8));
h3_cell_base
返回给定单元的 Base 单元。
SELECT h3_cell_base(h3_latlng_to_cell(37.76938, -122.3889, 8));
h3_cell_is_pentagon
如果单元格是五边形,则返回 true。
SELECT h3_cell_is_pentagon(h3_latlng_to_cell(37.76938, -122.3889, 8));
h3_cell_parent
返回给定分辨率下单元的父单元。
SELECT h3_cell_parent(h3_latlng_to_cell(37.76938, -122.3889, 8), 6);
h3_cell_center_child
返回指定分辨率下的中心子单元。目标分辨率必须大于或等于输入单元的分辨率。
SELECT h3_cell_center_child(h3_latlng_to_cell(37.76938, -122.3889, 8), 10);