1 建表
create table city (
fid serial primary key,
city_name VARCHAR(255),
geom geometry
)
2 插入数据
INSERT INTO city ( city_name, geom )
VALUES ('北京', st_geomfromtext('LINESTRING(0 0,1 1)', 4326));
insert into city(city_name,geom)
values('test','SRID=4326;polygon((112.784684 28.051125,省略省略省略省略省略,112.66978 28.205104))')
3 空间参考
3.1 查询空间参考
select st_srid(geom) from city;
3.2 更新空间参考
select UpdateGeometrySRID('city', 'geom', 4326);
4 距离、面积计算
单位:平方千米
select city_name,st_area(st_transform(geom,4527))/1000000 from city
未完待续