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?
2 Answers
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
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.
/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.