mysql空间数据处理,srid转换,点是否在空间内

Posted on 2024-05-30 10:44  zhuyu123  阅读(164)  评论(0编辑  收藏  举报

1、修改point点坐标srid

UPDATE points
SET geom = ST_GeomFromText(ST_AsText(geom), 4326)
WHERE ST_SRID(geom)=0;

2、修改POLYGON空间坐标srid

update points
set geom =ST_POLYGONFROMTEXT(ST_AsText(geom),4326,'axis-order=long-lat')
where st_srid(geom)=0

3、判断点是否在空间内

SELECT p1.id AS polygon_id, p1.name AS polygon_name,
               p2.id AS point_id, p2.name AS point_name,
              ST_Contains(p1.geometry, p2.geom) AS contains
FROM polygons p1, points p2

Copyright © 2025 zhuyu123
Powered by .NET 9.0 on Kubernetes