I'm trying to import a shapefile (boundary.shp) using shp2pgsql. I'm using the following query

shp2pgsql -I -s 4326 boundary ch01.test_boundary > psql -h -d spatial_database -U postgres

After running the above import statement I get the following message:

Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]

When I query for the table ch01.test_boundary it wasn't created, so it's failing.

I can successfully import the same shapefiles (get the same type messages, but the data is imported) using pgAdmin so I suspect it may have something to do with permissions.

I did notice i am not prompted for my password when running the above statement.

How can i resolve this?

1 Answer 1

shp2pgsql -I -s 4326 boundary ch01.test_boundary > psql -h -d spatial_database -U postgres

You need to use the pipe | to redirect output from shp2pgsql into psql. You were using >, which will try to write the output of shp2pgsql to a file. Nothing will be piped into psql.

  • Also, you probably now have a file called "psql" in wherever you ran the command.
    – BradHards
    Jun 10, 2017 at 1:11
  • @til ha I feel silly now, that was it!
    – Don
    Jun 10, 2017 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.