postgresql数据库经纬度转geometry

1、在postgresql数据库中,如果字段类型是geometry,更新该字段为经纬度(坐标),可以尝试采取以下脚本:

  注意:108.658463 代表经度 34.1437代表纬度 中间没有逗号

1 update table set geom = ST_GeomFromText('POINT(108.658463 34.1437)', 4490) where id = 123

2、一组几何坐标:

  注意:此时关键字为  POLYGON 

1 update building set geom = ST_GeomFromText('POLYGON((121.415703 31.172893,121.415805 31.172664,121.416127 31.172751,121.41603 31.172976,121.415703 31.172893))',4490) where id = 123

3、如果想要看geom的经纬度坐标:

1 SELECT ST_AsText(geom) FROM table where id = 123

 

posted @ 2020-08-27 14:22  RNGException  阅读(8103)  评论(1编辑  收藏  举报