0

I'm trying to import a shapefile into a non existing Postgis table. I'm using ogr2ogr with -sql option to select the fields from the shp that I would like to get imported however I would need a date field (that does not exists in my input shp) to be created in my output table. Is there any option within ogr2ogr for that ?

I've tried :

ogr2ogr -f "PostgreSQL" -a_srs "EPSG:4326" PG:"host=<db_host> user=<db_user> password=<db_password> dbname=<db_name>" -nlt MULTIPOLYGON -nln <table_name> -sql "SELECT <shp_field1> AS <pg_field1>,  <shp_field2> AS <pg_field2>,  current_date AS date FROM <shapeFile>" -overwrite <shapeFile>.shp

However I get an error 'Unrecognized field name current_date' which obviously does not exists in my input shapefile. Thanks for your help.

1 Answer 1

0

ok I get it to work by adding -dialect SQLite to by command line however it does not import the geometry anymore ...

1
  • ok just had to add geometry AS geom to the -sql command above Commented Jul 9, 2021 at 10:05

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.