I am trying to import in one single table different shapefiles using the command:

 shp2pgsql -D -s 4326 -c my_shapes_table -I *.shp  > my_shapes_table.sql

I have tried different combinations of the parameters but what I got are always multiple tables with the name of each single file. Any idea how to get one single table only that imports all the files?

  • 1
    By reading the manual bostongis.com/pgsql2shp_shp2pgsql_quickguide_20.bqg you should use -a for append. – user30184 Nov 10 '17 at 15:10
  • I tried that too without any luck - I don’t get how the options should be written – Randomize Nov 10 '17 at 15:11
  • There seem to be examples about looping through many files on the same page. I do not find anywhere that *.shp is supported, where did you learn to use that syntax? However, I am not sure if you can actually append to dump format. – user30184 Nov 10 '17 at 16:05
  • See this question. If you already have the table, you don't even need the if statement, you just use the -a flag and pipe everything to psql. This is obviously bash for linux, but you would be able to do something similar in Windows. – John Powell Nov 13 '17 at 7:02

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.