POSTGIS建表,增加点线面

1、建线表,插入线

SET CLIENT_ENCODING TO UTF8;

SET STANDARD_CONFORMING_STRINGS TO ON;

BEGIN;

CREATE TABLE "test2" (gid serial,

"field2" varchar(254));

ALTER TABLE "test2" ADD PRIMARY KEY (gid);

SELECT AddGeometryColumn('','test2','geom','0','LINESTRING',2);

insert into test2(field2, geom)

values('Triangle', ST_GeomFromText('LINESTRING(12 23, 26 30)', 4326));

commit;

包括建表语句

2、点和线基本一致,只需要把LINESTRING改为POINT即可

3、建面表,插入面这里注意:在拼写经纬度的时候是2层括弧包住的

SET CLIENT_ENCODING TO UTF8;

SET STANDARD_CONFORMING_STRINGS TO ON;

BEGIN;

CREATE TABLE "test1" (gid serial,

"field2" varchar(254));

ALTER TABLE "test1" ADD PRIMARY KEY (gid);

SELECT AddGeometryColumn('','test1','geom','0','POLYGON',2);

insert into test1(field2, geom)

values('Triangle', ST_GeomFromText('POLYGON((10 20, 20 40, 50 15, 10 20))', 4326));

commit;


你可能感兴趣的:(POSTGIS建表,增加点线面)