SELECT ST_GeometryFromText('POINT(116.39088 39.90763)',4326);

SELECT ST_GeomFromText('POINT(116.39088 39.90763)',4326);

SELECT ST_PointFromText('POINT(116.39088 39.90763)',4326);

 

1、创建点类型的表,类型不要选择postgresql提供的空间数据类型,要选择postgis提供的数据类型。

CREATE TABLE pointtable ( id SERIAL PRIMARY KEY, name VARCHAR(128), geom GEOMETRY(Point) );

4.PostGIS

 

2、插入点

INSERT INTO pointtable (name, geom) VALUES ('p1', ST_GeomFromText('POINT(120.205707 31.839323)', 4326) );

 

3、查询点

SELECT ST_X(geom) as x,ST_Y(geom) as y from pointtable;

--SRID=4326;POINT(120.205707 31.839323)

SELECT st_asewkt(geom) as point from pointtable;

--POINT(120.205707 31.839323)

SELECT ST_AsText(geom) as point from pointtable;

--{"type":"Point","coordinates":[120.205707,31.839323]}

SELECT ST_AsGeoJSON(geom) as point from pointtable;

 

 

相关文章:

  • 2021-08-07
  • 2022-01-09
  • 2021-11-26
  • 2020-11-12
  • 2021-11-03
  • 2020-04-28
  • 2019-11-22
  • 2021-11-20
猜你喜欢
  • 2021-10-03
  • 2021-11-29
  • 2018-01-13
  • 2021-11-29
  • 2021-11-29
  • 2021-04-27
  • 2021-11-24
  • 2021-10-16
相关资源
相似解决方案