3

How to convert post gis database into shapefile, I found that I need to use pgsql2shp command on postgis database query , But how to use it and where to use it. Do I have to use it in the postgre sql database command line or in the normal command line?

7
  • Welcome to GIS@SE, you need to specify what operating system and version you are using. Oct 5, 2014 at 5:03
  • Thanks. I am using linux 2.6.18. When I type pgsql2shp in command line I get an error saying command not found. Oct 5, 2014 at 5:38
  • 1
    It will be in wherever your postgres bin directory is, in my case,/usr/local/pgsql/bin/shp2pgsql. It might also be in /usr/bin/ or symlinked to the same. If you add your postgres install dir to your path, then you should be able to call pgsql2shp from anywhere. Oct 5, 2014 at 10:28
  • You need to install postgis locally to get this command.
    – Mike T
    Oct 6, 2014 at 2:41
  • I have it installed but still its not working Oct 6, 2014 at 3:10

2 Answers 2

3

The PostgreSQL Manual explains how to add the path to binaries to the PATH environment variable. This procedure depends on your OS distribution and how you installed PostgreSQL and/or PostGIS.


Otherwise, if you want to run a program like shp2pgsql without adding it to PATH, the path to the binary needs to be specified:

/usr/local/pgsql/bin/shp2pgsql example.shp public.example > example.sql
0

If you are using postGIS 2.x, and all is installed and configured properly, you can also run shp2pgsql-gui from the bash. In the window dialog select the tab "Export": now you are able to extract a postGIS table to shapefile format.

Your Answer

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

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