2

I have a shapefile which if I convert to sql statements using shp2pgsql return table name all in lowercase, for e.g. 'liberia'.

When I read the same shapefile using ogr and use layer.GetName() it returns capitalized name e.g. 'Liberia'.

Is the mismatch because I am not looking at the right variables?

3

Shp2pgsql converts all table and field names to lower case because Postgres prefers lower case table and field names, you have to put field names in quotes when you write queries with field names that have upper or mixed case names.

If you want to keep these identifiers uppercase use the "-k" switch in shp2pgsql.

http://www.bostongis.com/pgsql2shp_shp2pgsql_quickguide.bqg

https://stackoverflow.com/questions/20878932/are-postgresql-column-names-case-sensitive

1
  • 1
    ogr2ogr also support setting output layer name via -nln key. Also you can provide some layer creation options via -lco parameter (supported values see here: gdal.org/drv_pg.html) Feb 6 '17 at 7:42

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.