Skip to content

增改查Geometry类型字段

  • Insert 插入几何对象(不转换坐标系)
insert into test values(st_transform(st_geomfromtext('POINT
(10070507.650288 4282901.6281314)',900913))
  • Insert 插入几何对象(转换坐标系)
insert into test values(st_transform(st_geomfromtext('POINT
(10070507.650288 4282901.6281314)',900913),4326))
//采用postgis函数将墨卡托投影变成4326并插入空间数据库
POINT 
(10070507.650288 4282901.6281314) //标准wkt格式
  • Select 查询几何对象
select st_astext(location) from test;//返回对应的wkt
  • Update 更新几何对象
update table_name set the_geom = st_geomfromtext(ST_AsText(the_geom),4326)
// 注:此处4326为数据的坐标系ID)