0、对于表头有空格的情况,可以在sql查询中使用[]将表头包起来,使用单引号或者双引号 会引起不必要的麻烦
How to select a column name with a space in MySQL
1、计算polygon.shp中每个多边形的形心,输出到centroid.shp
ogr2ogr -sql "SELECT ST_Centroid(geometry), * FROM polygon" -dialect sqlite centroid.shp polygon.shp
2、选择水深大于5.0的多边形(注意命令行中单引号、双引号的使用)
ogr2ogr -sql ' SELECT * FROM centroid WHERE "Maximum cu">5.0 ' test.shp centroid.shp
3、输出点的xy坐标
ogr2ogr -sql "SELECT ST_X(geometry) as X, ST_Y(geometry) as Y, * FROM countries_centroid" -dialect sqlite -f CSV out.csv countries_centroid.shp
或者:
ogr2ogr -f CSV output.csv -lco GEOMETRY=AS_XY countries_centroid.shp
更新:2019-02-25,经实践,使用以下流程较好:
(1)先生成点文件
ogr2ogr -sql "select ST_Centroid(geometry),* from WU_20" -dialect sqlite centroid_WU_20.shp WU_20.shp
(2)再将点文件转换为CSV文件
ogr2ogr -dialect sqlite -sql "select ST_X(geometry) as centroid_X, ST_Y(geometry) as centroid_Y, [Maximum wa] as H from centroid_WU_50" -f CSV point_centroid_WU_50.csv centroid_WU_50.shp
没有评论:
发表评论