我有一个表rbeijing,有空间字段the_geom,但是是基于SRS4326的,我想用900913d的投影,所以就学要添加一个新的空间字段并转换投影坐标。做法如下:
mapdb=# alter table rbeijing add column the_geom_900913 geometry;
mapdb=# create index index_rbeijing_the_geom_900913 on rbeijing using gist(the_geom_900913);
mapdb=# create index index_rbeijing_the_geom on rbeijing gist(the_geom);
mapdb=# update table rbeijing set the_geom_900913=st_tranform(the_geom,900913);
mapdb=# update rbeijing set the_geom_900913 = st_transform(the_geom,900913);
mapdb=# \d rbeijing
Table "public.rbeijing"
Column | Type | Modifiers
-----------------+------------------------+--------------------------------------------------------
gid | integer | not null default nextval('rbeijing_gid_seq'::regclass)
mapid | character varying(8) |
id | character varying(13) |
kind_num | character varying(2) |
kind | character varying(23) |
width | character varying(3) |
direction | character varying(150) |
const_st | character varying(1) |
pathname | character varying(40) |
pathpy | character varying(250) |
snodeid | character varying(13) |
enodeid | character varying(13) |
pathclass | character varying(2) |
pathno | character varying(13) |
the_geom | geometry |
the_geom_900913 | geometry |
Indexes:
"rbeijing_pkey" PRIMARY KEY, btree (gid)
"index_rbeijing_the_geom" gist (the_geom)
"index_rbeijing_the_geom_900913" gist (the_geom_900913)
Check constraints:
"enforce_dims_the_geom" CHECK (ndims(the_geom) = 2)
"enforce_geotype_the_geom" CHECK (geometrytype(the_geom) = 'MULTILINESTRING'::text OR the_geom IS NULL)
"enforce_srid_the_geom" CHECK (srid(the_geom) = 4326)
上面的表结构是添加和转换后的。添加空间字段的同时,也为空间字段添加了索引。
操作前提:postgis/postgres能支持900913,如果不支持的话,就学要先添加900913投影支持。
|----------------------------------------------------------------------------------------|
版权声明 版权所有 @zhyiwww
引用请注明来源 http://www.blogjava.net/zhyiwww
|----------------------------------------------------------------------------------------|
posted on 2009-10-21 16:45
zhyiwww 阅读(679)
评论(0) 编辑 收藏 所属分类:
gis