John
John

Reputation: 659

Converting shapefiles using shp2pgsql

I know where shp2pgsql is in the postgresql directory but I'm not sure what commands to use after that. I've read the manual thoroughly, and I am aware of all the arguments and options for the shp2pgsql command. I get the error:

-bash: shp2pgsql: command not found

Is it a permissions problem perhaps?

Upvotes: 5

Views: 15871

Answers (2)

John
John

Reputation: 659

Solution is to export the path of the program and put it into $PATH variable. Another option is to move the command into directories already contained in PATH such as /usr/bin.

Example

export PATH=/Library/Postgresql/9.0/bin/:$PATH

or

  1. echo $PATH to find directories already there

  2. Go to directory with the program in it

  3. mv shp2pgsql /usr/bin for example

Upvotes: 1

Vincent
Vincent

Reputation: 227

The right command is «shp2pgsql», you have got a typo.

Usage example :

# shp2pgsql -c -D -s 4269 -I shaperoads.shp myschema.roadstable > roads.sql
# psql -d roadsdb -f roads.sql
  • -c creates the table
  • -I creates an index on geometry
  • -D uses dump format
  • -s specify projection srid

You first generate a sql file, which you then load into your database.

Upvotes: 13

Related Questions