PostGIS常用命令

1、查看表格空间字段坐标系

SELECT st_srid(geom) FROM shp_province limit 1;

2、修改几何字段空间参考

SELECT UpdateGeometrySRID('public', 'shp_province', 'geom', 4490);

此处shp_province原坐标系为WGS_84(4326),更换为CGCS 2000(4490)。其中,public为schema,shp_province为表名,geom为几何字段名称,4490为目标坐标系。

3、将WKB转换为WKT

    不含SRID

SELECT ST_AsText(geom) from shp_province limit 1;

    包含SRID

SELECT ST_AsEWKT(geom) from shp_province limit 1;

4、将WKT转为WKB

SELECT GeomFromEWKT('SRID=4326;POINT(108.5 33.5)') as wkb

5、面积统计,地理坐标系(4326),统计结果单位:平方公里

select ST_Area(Geography(geom))/1000000 as area from shp_province limit 1; 

 

转载自:https://blog.csdn.net/wm6752062/article/details/87777199

You may also like...