0

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 127.0.0.1 -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?

4
shp2pgsql -I -s 4326 boundary ch01.test_boundary > psql -h 127.0.0.1 -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.

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

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.