pgsql2shp(1)
β¨ NAME β¨
pgsql2shp β postgis to shapefile dumper π
okay bestie so this is the pgsql2shp(1) page from the PostGIS manual, and it's literally the little tool that yoinks your spatial data out of a database and drops it into a shapefile. no cap. π
π¦ SYNTAX π¦
pgsql2shp [options] database [schema.]table
pgsql2shp [options] database query
two ways in, bestie β point it at a table, or hand it a whole query. pick your fighter. πΈ
π DESCRIPTION π
The pgsql2shp table dumper connects directly to the database and converts a table (possibly created by user query) into a shape file. It is compatible with all versions of PostGIS. periodt. β¨
Version:1.1.5(2006/10/06) β yes she's been iconic for a while π«Ά
π USAGE π
The <database> is the name of the database to connect to. simple as that. π
The <table> is the (optionally schema-qualified) table to read spatial data from. Alternatively, you can specify a QUERY whose result will be written into the shapefile. so like, table or query, never both, she's not greedy. π
π OPTIONS π
The commandline options are:
-f <filename>β write the output to a particular filename. name your baby. πΌ-h <host>β the database host to connect to. where she at. π-p <port>β the port to connect to on the database host. πͺ-P <password>β the password to use when connecting to the database. π€«-u <user>β the username to use when connecting to the database. who dis. π-g <geometry column>β in the case of tables with multiple geometry columns, the geometry column to use when writing the shape file. you gotta pick which geometry column, bestie, she won't guess. π―-bβ use a binary cursor. When used on pre-1.0.0 PostGIS versions this will reduce the likelihood of coordinate drift due to conversion to and from WKT format. Coordinate drifts will not occur with PostGIS 1.0.0 and newer versions. It will be slightly faster, but might fail if any NON-geometry column lacks a cast to text. β‘-rβ raw mode. Do not drop thegidfield, or escape column names. no editing, no filters, we're going raw. π-dβ for backward compatibility: write a 3-dimensional shape file when dumping from old (pre-1.0.0) postgis databases (the default is to write a 2-dimensional shape file in that case). Starting from postgis-1.0.0+, dimensions are fully encoded. π-kβ keep identifiers case (don't uppercase field names). respect the lowercase, she has main character energy. π-m <filename>β specify a file containing a set of mappings of (long) column names to 10 character DBF column names. The content of the file is one or more lines of two names separated by white space and no trailing or leading space:
COLUMNNAME DBFFIELD1\n
AVERYLONGCOLUMNNAME DBFFIELD2\n
etc. π
-?β display version and usage information. a lil vibe check on the tool itself. β
π§ INSTALLATION π§
To compile the program from source, simply run "make" in the source directory. Then copy the binary in your shell search path (or wherever you like). This text is also available as a man page in the ../doc/man/ directory, ready for copying it into the manual search path on unixoid systems. slay and install. π
β¨
π₯ EXAMPLES π₯
An example session using the dumper to create shape file from a database might look like this:
# pgsql2shp -f myfile -p 5555 my_db roads_table
and that's it, she ate. π
π AUTHORS π
Originally written by Jeff Lounsbury <jeffloun@refractions.net>. Improved and maintained by Sandro Santilli <strk@kbt.io>. Includes small contributions and improvements by others. π«Ά
This application uses functionality from shapelib 1.2.9 by Frank Warmerdam <warmerda@gdal.velocet.ca> to write to ESRI Shape files. shoutout fr fr. πΈ
π SEE ALSO π
shp2pgsql(1)β the other half of the duo, iykyk π¦
More information is available at http://postgis.net π
okay that's the whole page bestie, no notes π this was the PostGIS pgsql2shp(1) manual, version 1.1.5 dated 2006/10/06, and she is still that girl. mwah, go dump some shapefiles. πβ¨π
π¦ where this page comes from
- alpine 3.24: postgis-doc 3.6.3-r0 Β· GPL-2.0-or-later
- arch rolling: postgis 3.6.4-1 Β· GPL-2.0-or-later
- centos-stream 10: postgis-client 3.5.3-4.el10 Β· GPL-2.0-or-later
- centos-stream 10: postgresql18-postgis-client 3.5.3-2.el10 Β· GPL-2.0-or-later
- centos-stream 9: postgis-client 3.6.1-1.module_el9+1300+1c4aa8df Β· GPL-2.0-or-later
- debian bookworm: postgis 3.3.2+dfsg-1+b1 Β· GPL-2.0-or-later
- debian trixie: postgis 3.5.2+dfsg-1 Β· GPL-2.0-or-later
- fedora 43: postgis-client 3.6.0-1.fc43 Β· GPL-2.0-or-later
- fedora 43: postgis-client 3.6.4-5.fc43 Β· GPL-2.0-or-later
- fedora 43: postgresql16-postgis-client 3.6.4-5.fc43 Β· GPL-2.0-or-later
- fedora 43: postgresql17-postgis-client 3.6.4-5.fc43 Β· GPL-2.0-or-later
- fedora 44: postgis-client 3.6.2-1.fc44 Β· GPL-2.0-or-later
- fedora 44: postgis-client 3.6.4-5.fc44 Β· GPL-2.0-or-later
- fedora 44: postgresql16-postgis-client 3.6.2-1.fc44 Β· GPL-2.0-or-later
- fedora 44: postgresql16-postgis-client 3.6.4-5.fc44 Β· GPL-2.0-or-later
- fedora 44: postgresql17-postgis-client 3.6.2-1.fc44 Β· GPL-2.0-or-later
- fedora 44: postgresql17-postgis-client 3.6.4-5.fc44 Β· GPL-2.0-or-later
- nixos 26.05: postgis 3.6.4
- nixpkgs unstable: postgis 3.6.4
- ubuntu jammy: postgis 3.2.0+dfsg-1ubuntu1 Β· GPL-2.0-or-later
- ubuntu noble: postgis 3.4.2+dfsg-1ubuntu3 Β· GPL-2.0-or-later
- ubuntu questing: postgis 3.5.3+dfsg-2build1
- ubuntu resolute: postgis 3.6.2+dfsg-1 Β· GPL-2.0-or-later
- ubuntu stonking: postgis 3.6.4+dfsg-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms