将已知文本 (WKT) 字符串转换为 GeoJSON 形状。
语法
geo_from_wkt(
wkt)
详细了解语法约定。
参数
名称 | 类型 | 必选 | DESCRIPTION |
---|---|---|---|
wkt | string |
✔️ | 几何图形的已知文本表示形式字符串。 |
退货
GeoJSON 格式和动态数据类型的形状。 如果输入 WKT 字符串无效或不受支持,查询将生成 null 结果。
注释
地理空间坐标解释为 WGS-84 坐标参考系统表示。
小窍门
- 使用转换和存储的 GeoJSON 形状可能会导致地理空间分析的性能更好。
例子
以下示例将点从 WKT 格式转换为 GeoJSON 格式。
print point = geo_from_wkt("POINT (1 2)");
输出
点 |
---|
{“type”: “Point”,“coordinates”: [1,2]} |
以下示例将行从 WKT 格式转换为 GeoJSON 格式。
print line = geo_from_wkt("LINESTRING (1 2, 3 4)");
输出
线 |
---|
{“type”: “LineString”, “coordinates”: [[1,2],[3,4]]} |
以下示例将多边形从 WKT 格式转换为 GeoJSON 格式
print polygon = geo_from_wkt("POLYGON ((0 0, 2 0, 2 2, 0 0))");
输出
多边形 |
---|
{“type”: “Polygon”,“coordinates”: [[[0,0],[2,0],[2,2],[0,0]]]} |
以下示例将多点从 WKT 格式转换为 GeoJSON 格式。
print multipoint = geo_from_wkt("MULTIPOINT (1 1, 2 2, 3 3)");
输出
多点 |
---|
{“type”: “MultiPoint”,“coordinates”: [[1,1],[2,2],[3,3]]]} |
以下示例将多行从 WKT 格式转换为 GeoJSON 格式。
print multiline = geo_from_wkt("MULTILINESTRING ((1 1, 2 2, 3 3), (4 4, 5 5))");
输出
多行 |
---|
{“type”:“MultiLineString”,“coordinates”:[[[1,1],[2,2],[3,3]],[[4,4],[5,5]]]} |
以下示例将 multipolygon 从 WKT 格式转换为 GeoJSON 格式。
print multipolygon = geo_from_wkt("MULTIPOLYGON (((0 0, 2 0, 2 2, 0 0)),((10 10, 12 10, 12 12, 10 10)))");
输出
multipolygon |
---|
{“type”: “MultiPolygon”,“coordinates”: [[[[0,0],[2,0],[2,2],[0,0],[10,10],[12,10],[12,12],[10,10]]]} |
以下示例将几何图形集合从 WKT 格式转换为 GeoJSON 格式。
print geometry_collection = geo_from_wkt("GEOMETRYCOLLECTION (POINT (1 1),LINESTRING (2 2, 3 3, 4 4),POLYGON ((10 10, 12 10, 12 12, 10 10)))");
输出
geometry_collection |
---|
{“type”:“GeometryCollection”,“geometries”:[{“type”:“Point”,“coordinates”:[1,1]},{“type”:“LineString”,“coordinates”:[[2,2],[3,3],[[3,3],[[4,4]},{“type”:“Polygon”,“coordinates”:[[[10,10],[12,10],[12,12],[10,10]]]}]} |
下面的示例由于 WKT 字符串无效而返回 null 结果。
print result = isnull(geo_from_wkt("LINESTRING"))
输出
结果 |
---|
是 |