You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

QGIS技术问询:如何移除geom_to_wkt()返回结果中的"Point"文本

QGIS布局中显示地图中心点纯UTM坐标数值的解决方法

方法1:直接提取坐标值(推荐)

跳过WKT格式中转,直接提取转换后中心点的横纵坐标并拼接,表达式简洁高效:

[%
    # 将地图中心坐标转换为目标UTM坐标系(EPSG:32755)
    target_center = transform(map_get(item_variables('map_1'), 'map_extent_center'), 'EPSG:3857', 'EPSG:32755');
    # 提取并拼接x、y坐标,可自定义分隔符(这里用逗号+空格)
    x(target_center) || ', ' || y(target_center)
%]

如果需要固定小数位数,可搭配round()函数,比如round(x(target_center), 2)来保留2位小数。

方法2:正则替换清理WKT结果

如果要保留原有的geom_to_wkt逻辑,可用正则表达式去掉Point()前缀和后缀:

[% regex_replace(geom_to_wkt(transform(map_get(item_variables('map_1'), 'map_extent_center'), 'EPSG:3857', 'EPSG:32755'), 0), '^Point\\((.*)\\)$', '\\1') %]

原理:通过regex_replace匹配Point(x y)的WKT结构,提取出括号内的坐标数值部分。

额外优化:规范坐标显示格式

如果需要更清晰的标注(比如明确X/Y轴),可调整拼接逻辑:

[%
    target_center = transform(map_get(item_variables('map_1'), 'map_extent_center'), 'EPSG:3857', 'EPSG:32755');
    'X: ' || round(x(target_center), 2) || ' | Y: ' || round(y(target_center), 2)
%]

内容的提问来源于stack exchange,提问作者dwids

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 13:15:53