2019年12月2日星期一

gdal:shape文件添加面积属性

ogrinfo -al -so         2max_elements_0.shp

ogrinfo  -sql       "alter table  \"2max_elements_0\"  add column area real(20,3)" 2max_elements_0.shp

ogrinfo  -dialect SQLite -sql   "update \"2max_elements_0\" set area = ST_Area(geometry)" 2max_elements_0.shp


备注:

Because UPDATE is not supported in OGR SQL, you should update the table using the SQLite SQL dialect available in GDAL >= 1.10 with SQLite and SpatiaLite support.[1]

GDAL is internally using the Virtual Table Mechanism of SQLite and therefore operations like ALTER TABLE are not supported. [2]

没有评论: