I've a point ESRI shapefile in ESPG32632 spatial reference.
I need to add X and Y column to it and I'd like to use something from command line like ogr2ogr but I don't know the syntax.
Any example?
Answer
Use the OGR SQL http://www.gdal.org/ogr_sql.html and add X and Y columns with
ogrinfo foo.shp -sql "alter table foo add column X double"
ogrinfo foo.shp -sql "alter table foo add column Y double"
Then switch to SQLite dialect http://www.gdal.org/ogr_sql_sqlite.html
ogrinfo foo.shp -dialect SQLite -sql "update foo set X=ST_X(geometry)"
ogrinfo foo.shp -dialect SQLite -sql "update foo set Y=ST_Y(geometry)"
No comments:
Post a Comment