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 the gid field, 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