-3

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?

1
  • 3
    A good question should include your attempt and detail of what happens when you try it. What have you tried? Please edit your question to include this information.
    – Midavalo
    Commented Apr 16, 2017 at 15:20

1 Answer 1

2

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))"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.