I use shp2pgsql to append a shapefile to an existing table.

How can I define the table where I want to append the shapefile in PostGIS?

This is the command I execute with Python:

command = "shp2pgsql -s 4326 -a shape_file.shp | psql -h localhost -p 5432 -d gis_exercise -U postgres" 

But this commands generates a table with the name of the shapefile.


You should add the schemaname and tablename to the command. Like this:

shp2pgsql -s 4326 -I [naam].shp [schemaname].[tablename]  | psql -h [host] -d [database] -U [user]

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.