I've a point shapefile in ESPG 32632 spatial reference.
To add X and Y columns I've used Add X, Y column to a ESRI shapefile using ogr2ogr and it works fine.
Now I need to add also Lat and Lon columns to store coordinates in EPSG4326 and I'd like to use something from command line like ogr2ogr but I don't know the syntax.
Any example?
Answer
The answer is the same of Add X, Y column to a ESRI shapefile using ogr2ogr you cited, except that we have to transform the geometry to EPSG:4326 in order to calculate the geographical coordinates using for instance the SpatiaLite ST_Transform function:
ogrinfo points.shp -sql "ALTER TABLE points ADD COLUMN LON double"
ogrinfo points.shp -sql "ALTER TABLE points ADD COLUMN LAT double"
ogrinfo points.shp -dialect SQLite -sql "UPDATE points SET LON=ST_X(ST_Transform(geometry,4326))"
ogrinfo points.shp -dialect SQLite -sql "UPDATE points SET LAT=ST_Y(ST_Transform(geometry,4326))"
No comments:
Post a Comment