I'm trying to rename a layer while converting it from a shapefile to sqlite. From looking at the ogr2ogr documents, -nln name should do the trick. I've seen this similar post and this very similar post but neither will work for me.

ogr2ogr -f "sqlite" output.sqlite input.shp -nln "new_layer_name"
  • That's the way to do it. Do you mean that "ogrinfo output.sqlite" does not list "new_layer_name"?
    – user30184
    Jan 8 '18 at 17:16
  • Yes, the layer name does not change
    – Walshe_d
    Jan 8 '18 at 17:36
  • Can you post the output of ogrinfo -so -al output.sqlite ?
    – dmci
    Jan 8 '18 at 19:37
  • ... and maybe the same on the input file?
    – AndreJ
    Jan 9 '18 at 7:10

I can't reproduce with GDAL 2.3.0dev.

Create a SQLite database with -nln parameter

ogr2ogr -f "sqlite" output.sqlite states.shp -nln "new_layer_name"

Check the result with ogrinfo

ogrinfo output.sqlite
INFO: Open of output.sqlite using driver `SQLite' successful.
1: new_layer_name (Polygon)

The layer appears in the database as it was named with the -nln parameter.

  • I checked the file using QGIS and read it's layer name from there which was showing it hadn't changed. When when i used ogrinfo the change was visible
    – Walshe_d
    Jan 8 '18 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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