pgsql2shp
is a command-line tool that can be used to output PostGIS data into shapefiles. Similarly to outgoing \COPY
, it can either export a full table or the result of a query, so this gives us flexibility when we only need a subset of data to be outputted and we do not want to either modify the source tables or create temporary, intermediate ones.
In order to get some help with the tool just type the following in the console:
pgsql2shp
The general syntax for the tool is as follows:
pgsql2shp [<options>] <database> [<schema>.]<table> pgsql2shp [<options>] <database> <query>
Shapefile is a format that is made up of a few files. The minimum set is SHP, SHX, and DBF. If PostGIS is able to determine the projection of the data, it will also export a PRJ file that will contain the SRS information, which should be understandable by the software able to consume a shapefile.
If a table does not have...