
1
GIS是什么
2
GIS应用

3
PostGIS是什么
4
PostGIS应用
create table t_point(gid serial primary key,name text,geom geometry(point,4326));
insert into t_point values (1,'点','point(0 0)');
create table t_line(gid serial primary key,name text,geom geometry(linestring,26910));
insert into t_line values (1,'线','linestring(0 0,1 1,1 2)');
create table t_polygon(gid serial primary key,name text,geom geometry(polygon,26910));
insert into t_polygon values (1,'面','polygon((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))');
select * from t_point;
select * from t_line;
select * from t_polygon;

建表并插入栅格数据:
' || '0000000000000000' || '00000000' || '0A00' || '1400' )::raster ), (2, ('01000003009A9999999999A93F9A9999999999A9BF000000E02B274A' || '41000000007719564100000000000000000000000000000000FFFFFFFF050005000400FDFEFDFEFEFDFEFEFDF9FAFEF' ||
'EFCF9FBFDFEFEFDFCFAFEFEFE04004E627AADD16076B4F9FE6370A9F5FE59637AB0E54F58617087040046566487A1506CA2E3FA5A6CAFFBFE4D566DA4CB3E454C5665')::raster);
select st_srid(rast) as srid from t_rast;

(1) 创建包含几何类型表并插入10万条数据;
create table t_gist(id int, pos point);
insert into t_gist select generate_series(1,100000), point(round((random()*1000)::numeric, 2), round((random()*1000)::numeric, 2));
(2) 创建GIST类型索引;
create index idx_t_gist on t_gist using gist(pos);
(3) 使用查询语句并显示执行计划,确认使用了GIST索引。
explain (analyze,verbose,timing,costs,buffers) select * from t_gist where circle '((100,100) 10)' @> pos;

select ST_AsText(geom) from t_point;
select ST_AsEWKT(geom) from t_line;
select ST_AsText(geom) from t_polygon;

select ST_AsBinary(geom) from t_point;
select ST_AsBinary(geom) from t_line;
select ST_AsBinary(geom) from t_polygon;

create table stations ( id varchar(12) primary key, lonlat geometry(Point,4326), area float8, polygon geometry(Polygon,4326) );
insert into stations (id, lonlat, area, polygon) VALUES ('A12345',ST_GeomFromText('POINT(121.50 31.22)',4326),22222.1234,ST_GeomFromText('POLYGON ((121.71436091670316 31.38080337674083, 121.70173615072089 31.388605486784197, 121.70751628677645 31.4199972067024, 121.71832867120243 31.437168981489133, 121.73193985623796 31.37984624401758, 121.71436091670316 31.38080337674083))',4326));


insert into stations (id, lonlat, area, polygon) VALUES ('A12347',ST_GeomFromText('POINT(121.50 31.22)',4326),22222.1234,ST_GeomFromText('POLYGON ((121.71436091670316 31.38080337674083, 121.70212345678233 31.388605486784197, 121.70628392347901 31.4199972067024, 121.71132867120243 31.437168981489133, 121.73193985623796 31.37984624401758, 121.71436091670316 31.38080337674083))',4326));


05
前景广阔

文章转载自瀚高数据库,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




