1

I am trying to import features from a geopackage (or a shapefile) in an existing table of a distant PostgreSQL database. I use ogr2ogr which I run from OSGeo4W Shell.

The code used with the geopackage is:

ogr2ogr -update -append -progress -f PostgreSQL -nln schema.my_table PG:"dbname=my_database host=my_server user=me password=my_password port=5433" D:\temp\SIG\my_geopackage.gpkg

The code used with the shapefile (an export from the gpkg) is:

ogr2ogr -update -append -progress -f PostgreSQL -sql "SELECT [variables as var] from my_shapefile" -nln schema.my_table PG:"dbname=my_database host=my_server user=me password=my_password port=5433" D:\temp\SIG\my_shapefile.shp

(in this case I must call a select to rename the variables as their name is truncated by the conversion in shp)

In both case, I get a "done" message and I can find the data is my_table BUT their are not spatial anymore... I mean I can't see the polygons corresponding to each line.

What do I do wrong?

12
  • Do you have the postgis extension installed for your postgres database? Aug 17 at 12:11
  • Yes, the extension is installed. I can see all the previous polygones from QGIS but not the new ones... Maybe it can be usefull to say that the table contains both polygones, polylines and points... In this case I am only importing polygones.
    – D_Laf
    Aug 17 at 12:15
  • have you tried putting your source path in quotes? "D:\temp\SIG\my_geopackage.gpkg" Aug 17 at 12:22
  • I've just tried: it gives the same results...
    – D_Laf
    Aug 17 at 12:36
  • Hmm alright, could you be more specific about what you mean by 'the polygons corresponding to each line? And how do you know they're not spatial anymore? Aug 17 at 12:42

Your Answer

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

Browse other questions tagged or ask your own question.